datagridview显示行号
2012-09-25 16:50
253 查看
private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
Rectangle rectangle = new Rectangle(e.RowBounds.Location.X,
e.RowBounds.Location.Y,
dataGridView1.RowHeadersWidth - 4,
e.RowBounds.Height);
TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(),
dataGridView1.RowHeadersDefaultCellStyle.Font, rectangle,
dataGridView1.RowHeadersDefaultCellStyle.ForeColor,
TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
}
另一种也是在这个事件下面下面 用了个for循环来做index+1的单元格赋值,效率太慢了。
{
Rectangle rectangle = new Rectangle(e.RowBounds.Location.X,
e.RowBounds.Location.Y,
dataGridView1.RowHeadersWidth - 4,
e.RowBounds.Height);
TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(),
dataGridView1.RowHeadersDefaultCellStyle.Font, rectangle,
dataGridView1.RowHeadersDefaultCellStyle.ForeColor,
TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
}
另一种也是在这个事件下面下面 用了个for循环来做index+1的单元格赋值,效率太慢了。
相关文章推荐
- C# DataGridView显示行号、行选中
- DataGridView自动显示行号(VB.NET)
- C#中的datagridview显示行号
- 让DataGridView显示行号
- DataGridView 显示行号
- 让DataGridView显示行号
- DataGridView控件显示行号的正确代码及分析
- datagridview动态绑定以及显示行号
- C# 中 datagridview控件 在行标题显示行号的方法
- Winform中的DatagridView显示行号
- DataGridView显示行号
- 在DataGridView中显示行号
- datagridview 显示行号、插入多行、删除、插入、清空行
- 在DataGridView中显示行号(C#)
- C#--操作DataGridView控件详解(数据显示,更改行高行宽,交换行,自动添加行号)
- DataGridView行号显示实现
- DataGridView显示行号
- [转]DataGridView显示行号
- DataGridView显示行号
- 让DataGridView显示行号