【发布时间】:2020-06-03 17:04:28
【问题描述】:
我知道复选框大小可以这样改变。
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);
}
}
}
【问题讨论】:
-
您可以发布您尝试过的代码。
-
对不起,因为我认为覆盖 Paint 似乎是错误的方向,所以没有发布。