vs2005 DataGridView添加行号
2009-05-30 14:00
411 查看
在DataGridView的RowPostPaint事件中添加:
private void dgvDetail_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) { //using (SolidBrush b = new SolidBrush(dgvDetail.RowHeadersDefaultCellStyle.ForeColor)) //{ // e.Graphics.DrawString((e.RowIndex + 1).ToString(), e.InheritedRowStyle.Font, b, e.RowBounds.Location.X + 10, e.RowBounds.Location.Y + 4); //} Rectangle rectangle = new Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, this.dgvDetail.RowHeadersWidth - 4, e.RowBounds.Height); TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), dgvDetail.RowHeadersDefaultCellStyle.Font, rectangle, dgvDetail.RowHeadersDefaultCellStyle.ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.Right); }
相关文章推荐
- C# winform 和Webform 给DataGridView 和DataView 添加行号
- DataGridView 自动在行头添加行号
- 为DataGridView添加行号
- 将dataGridView中的添加/删除等修改保存至数据库(winform - VS2005)
- Winform 程序中DataGridView 控件添加行号
- Winform中的DataGridView添加行号
- 在DataGridView中自动添加行号到因定列上
- 为datagridView添加行号
- 为 DataGridView 添加行号
- VS2005设置(显示行号,更改字体,添加运行按钮)
- dataGridView添加行号
- 为 DataGridView 控件添加行号
- 为DataGridView添加行号
- 在DataGridView中添加行号
- 为 DataGridView 添加行号
- 在DataGridView中添加行号
- DataGridView初始化——添加列、添加行号、连接数据库、单击单元格在文本框中显示
- C#的DataGridView中自动在行首添加行号
- DataGridView添加行号
- dataGridView添加行号