DataGridView之编码列重绘
2024-09-20 11:17:41
实现方式如下:
private void dgvRelation_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
try
{
SolidBrush b = new SolidBrush(this.dgvRelation.RowHeadersDefaultCellStyle.ForeColor);
e.Graphics.DrawString((e.RowIndex + 1).ToString(System.Globalization.CultureInfo.CurrentUICulture),
this.dgvRelation.DefaultCellStyle.Font, b, e.RowBounds.Location.X + 20, e.RowBounds.Location.Y + 4);
}
catch { return; }
}
效果如下:
注意:使用该方式处理编号列的显示,需要处理cell_click事件,如: if (e.RowIndex == -1||e.ColumnIndex==-1) return;
最新文章
- Linux下定时执行脚本(转自Decode360)
- Python WebDriver自动化测试
- CI(持续集成)CD(持续交付)
- sqlserver存取过程游标
- [UWP]涨姿势UWP源码——极简的RSS阅读器
- 10324 Global Warming dfs + 二分
- Uva120 Stacks of Flapjacks 翻煎饼
- int 0x13中断的參数传递
- HDU 1004 - Let the Balloon Rise(map 用法样例)
- Attempt to write to field 'android.support.v4.app.FragmentManagerImpl android.support.v4.app.Fragment.mFragmentManager' on a null object reference
- Php和httpd.conf的配置
- Jsp制作验证码
- Elixir东游记/上:intro/1
- 第五章 绘图基础(DEVCAPS1)
- Go语言实战 (William,Kennedy 等著)
- WPF 获取文件夹路径,目录路径,复制文件,选择下载文件夹/目录
- linux命令学习之:sort
- 数据库迁移之从oracle 到 MySQL最简单的方法
- Linq To EF (添加记录后获取添加的自增ID和叫“ID”的列不是自增列不让插入的问题)
- cocoaPods 创建自己的依赖库