private void datagv_det_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
SolidBrush b = new SolidBrush(this.datagv_det.RowHeadersDefaultCellStyle.ForeColor);
e.Graphics.DrawString((e.RowIndex + 1).ToString(System.Globalization.CultureInfo.CurrentUICulture), this.datagv_det.DefaultCellStyle.Font, b, e.RowBounds.Location.X + 20, e.RowBounds.Location.Y + 4);
}
本文介绍了一个使用C#实现DataGridView自定义行绘制的方法。通过重写RowPostPaint事件,可以在DataGridView的每一行前添加行号。此代码段适用于需要自定义DataGridView显示效果的应用程序开发。
66

被折叠的 条评论
为什么被折叠?



