给DataGridView加上行号吧[C#、WinForm]
2010-04-30 16:14
369 查看
在显示很多记录时,给DataGridView加上行号会提高用户体验。注意在dataGridView的RowPostPaint事件中实现:
///给DataGridView加上行号 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); }
相关文章推荐
- C# winform 和Webform 给DataGridView 和DataView 添加行号
- C# Winform DataGridView分页功能的实现
- C# WinForm开发系列 - DataGridView
- c# winform 用代码修改DataGridView列头的名字,设置列名,修改列名
- C#的winform中控制TextBox中只能输入数字(加上固定位数和首位不能为0)
- C# winform DatagridView 的简单操作
- C# Winform DataGridView单元格合并
- C# WinForm开发 DataGridView控件的各种操作总结(单元格操作,属性设置)
- C#winform datagridview如何自定义列头
- 基于C#的WinForm中DataGridView控件操作汇总
- C# WinForm下DataGridView单选按钮列和支持三种选择状态的复选框列的实现
- C# winform DataGridView导出到EXCEL
- C# winform datagridview 无需点击两次即可编辑内嵌控件的方法和删除默认的空行的方法
- c# winform datagridview 控件 删除最左边一列
- c# winform 怎么给程序的按钮上也加上小盾牌图标
- c# winform:当子窗体关闭时,更新父窗体DataGridView控件的值
- C#Winform基础 datagridview控件取消最左边存储行标题的列
- C# Winform DataGridView 公共分页实现
- C# WinForm开发系列 - DataGridView
- C# WinForm DataGridView控件使用