private void dataGridView1_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);
}
本文介绍了一个在DataGridView控件中自定义显示行序号的方法。通过使用RowPostPaint事件,可以实现在每行前面绘制指定样式的序号。这种方法适用于需要对表格行进行特殊标识的应用场景。
66

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



