C#之重新绘制DataGridView的选择框
/// <summary>
/// 重新绘制DataGridView的选择框
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DgvUrlPath_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.ColumnIndex == 0 && e.RowIndex == 0)
{
e.PaintBackground(e.CellBounds, true);
ControlPaint.DrawCheckBox(e.Graphics, e.CellBounds.X + 5, e.CellBounds.Y + 5, //选择框的位置
e.CellBounds.Width - 10, e.CellBounds.Height - 10, //选择框的大小
(bool)e.FormattedValue ? ButtonState.Checked : ButtonState.Normal);
e.Handled = true;
}
}
本文来自博客园,作者:小康0,转载请注明原文链接:https://www.cnblogs.com/z13753176959/p/17765616.html
浙公网安备 33010602011771号