private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
SolidBrush brush = new SolidBrush(dataGridView1.RowHeadersDefaultCellStyle.ForeColor);
int line = 0;
line = e.RowIndex + 1;
string s_line = line.ToString();
e.Graphics.DrawString(s_line,e.InheritedRowStyle.Font,brush,e.RowBounds.Location.X+15,e.RowBounds.Location.Y+5);
}
DataGridView增加序号
最新推荐文章于 2024-10-08 12:51:24 发布
本文介绍了一个在DataGridView控件中自定义显示行号的方法。通过使用RowPostPaint事件,可以实现在每行前面绘制指定样式的行号,示例代码展示了如何设置字体颜色及位置。
4863

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



