C# winfrom中 DataGridView中显示行号
2010-12-02 16:52
519 查看
在DataGridView里加上这个事件RowPostPaint
private void dataGridView1_[color=red]RowPostPaint[/color](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);
}
private void dataGridView1_[color=red]RowPostPaint[/color](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);
}
相关文章推荐
- C# WinFrom 中如何将txt内容显示到dataGridView
- C# Winfrom Datagridview 下方添加统计行
- c# winFrom 使窗体显示SplitContainer或Panel中
- c#中dataGridView显示行号的方法
- C# 、Vb .Net 中 Datagridview显示行号方法。
- [转]c# winFrom 使窗体显示SplitContainer或Panel中
- C# DataGridView显示行号的三种方法
- c# winFrom 使窗体显示SplitContainer或Panel中
- C# 中 datagridview控件 在行标题显示行号的方法
- C# DataGridView显示行号方法。
- C# Winfrom设置DataGridViewColumn标题对齐方式TitleAlignment
- c# winFrom 使窗体显示SplitContainer或Panel中[转]
- [转]c# winFrom 使窗体显示SplitContainer或Panel中
- c# winfrom DataGridView使行高不可改变,使列头高度不可改变,
- C#WinFrom程序 打印,不显示取消对话框
- C# DataGridView显示行号、行选中
- C# DataGridView显示行号的三种方法
- C# DataGridView显示行号的两种方法
- C# winfrom下即时显示输出信息 ,比如for循环不等执行完一次输出
- c# winfrom 全屏显示,遮盖任务栏,解决闪屏问题