让DataGridView显示行号
2014-06-16 09:40
211 查看
/article/4967796.html
为了表示行号,我们可以在DataGridView的RowPostPaint事件中进行绘制。RowPostPaint事件,具体可以参照MSDN。
下面是实现代码:
private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
System.Drawing.Rectangle rectangle =
new System.Drawing.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);
}
来自为知笔记(Wiz)
为了表示行号,我们可以在DataGridView的RowPostPaint事件中进行绘制。RowPostPaint事件,具体可以参照MSDN。
下面是实现代码:
private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
System.Drawing.Rectangle rectangle =
new System.Drawing.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);
}
来自为知笔记(Wiz)
相关文章推荐
- C# DataGridView显示行号的三种方法
- DataGridView初始化——添加列、添加行号、连接数据库、单击单元格在文本框中显示
- datagridview 显示行号、插入多行、删除、插入、清空行
- C# 、Vb .Net 中 Datagridview显示行号方法。
- DataGridView显示行号的方法
- DataGridView控件显示行号
- datagridview显示行号
- winform让DataGridView显示行号
- 让DataGridView显示行号
- datagridview动态绑定以及显示行号
- DataGridView自动显示行号(VB.NET)
- C# winfrom中 DataGridView中显示行号
- DataGridView显示行号-RowPostPaint
- C# DataGridView显示行号方法。
- 让DataGridView显示行号
- DataGridView 显示行号
- 让DataGridView显示行号
- C# 中 datagridview控件 在行标题显示行号的方法
- DataGridView控件显示行号的正确代码
- DataGridView显示行号