您的位置:首页 > 编程语言 > C#

C#中的datagridview显示行号

2015-05-07 16:43 405 查看
private void DGV_DataInfo_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)

{

var dgv = sender as DataGridView;

if (dgv != null)

{

Rectangle rect = new Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, dgv.RowHeadersWidth - 4, e.RowBounds.Height);

TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), dgv.RowHeadersDefaultCellStyle.Font, rect, dgv.RowHeadersDefaultCellStyle.ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.Right);

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: