我知道复选框的大小可以像这样改变。如何更改DatagridviewCheckboxCell中的复选框大小
checkBox1.Size = new Size(10, 10);
我想改变与DataGridViewCheckBoxColumn DataGridView中的复选框的大小,我想继承DatagridviewCheckboxCell,但没有发现任何方式做相同。
class DGCBC : DataGridViewCheckBoxColumn
{
public DGCBC()
{
this.CellTemplate = new DatagridviewCheckboxCustomCell();
}
class DatagridviewCheckboxCustomCell : DataGridViewCheckBoxCell
{
public int row_index { get; set; }
/// <summary>
/// constructor
/// </summary>
///
public DatagridviewCheckboxCustomCell()
{
}
protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState,
object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle,
DataGridViewPaintParts paintParts)
{
*//I tried many way in there,but it's not work*
base.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
}
}
}
你可以发布你试过的代码。 – Shanid
对不起,因为我认为重写Paint看起来是错误的方向,所以没有发布。 – Jason
检查了这一点:http://stackoverflow.com/questions/10117477/how-to-change-checkbox-size-in-datagridview-winform – princevezt