winform datagridview行头添加序号
作者:互联网
1、使用datagirdview的RowPostPaint事件
2、datagirdview命名为dgv。(当然这个名字随意,开心就好)
3、贴代码
private void dgv_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) { SolidBrush b = new SolidBrush(this.dgv.RowHeadersDefaultCellStyle.ForeColor); e.Graphics.DrawString((e.RowIndex + 1).ToString(System.Globalization.CultureInfo.CurrentUICulture), this.dgv.DefaultCellStyle.Font, b, e.RowBounds.Location.X + 20, e.RowBounds.Location.Y + 4); }
标签:Location,RowPostPaint,datagridview,行头,dgv,RowBounds,datagirdview,SolidBrush,winf 来源: https://www.cnblogs.com/bklsj/p/15091332.html