private void dgvGoodsInfo_RowPostPaint
(object sender, DataGridViewRowPostPaintEventArgs e)
{ //为数据行加标号
using (SolidBrush b = new SolidBrush
(dgvGoodsInfo.RowHeadersDefaultCellStyle.ForeColor))
{ e.Graphics.DrawString(
e.RowIndex.ToString(System.Globalization.CultureInfo.CurrentUICulture), dgvGoodsInfo.DefaultCellStyle.Font,
b, e.RowBounds.Location.X+20, e.RowBounds.Location.Y+4);
}
}
本文介绍了一种在DataGridView控件中自定义显示行编号的方法。通过使用RowPostPaint事件,可以实现在每一行前面显示行索引的功能,并且能够自定义字体颜色和位置。
1073

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



