实现方式如下:

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;

最新文章

  1. Linux下定时执行脚本(转自Decode360)
  2. Python WebDriver自动化测试
  3. CI(持续集成)CD(持续交付)
  4. sqlserver存取过程游标
  5. [UWP]涨姿势UWP源码——极简的RSS阅读器
  6. 10324 Global Warming dfs + 二分
  7. Uva120 Stacks of Flapjacks 翻煎饼
  8. int 0x13中断的參数传递
  9. HDU 1004 - Let the Balloon Rise(map 用法样例)
  10. Attempt to write to field 'android.support.v4.app.FragmentManagerImpl android.support.v4.app.Fragment.mFragmentManager' on a null object reference
  11. Php和httpd.conf的配置
  12. Jsp制作验证码
  13. Elixir东游记/上:intro/1
  14. 第五章 绘图基础(DEVCAPS1)
  15. Go语言实战 (William,Kennedy 等著)
  16. WPF 获取文件夹路径,目录路径,复制文件,选择下载文件夹/目录
  17. linux命令学习之:sort
  18. 数据库迁移之从oracle 到 MySQL最简单的方法
  19. Linq To EF (添加记录后获取添加的自增ID和叫“ID”的列不是自增列不让插入的问题)
  20. cocoaPods 创建自己的依赖库

热门文章

  1. 2.9 iframe
  2. C高级第二次PTA作业
  3. 2017 乌鲁木齐赛区网络赛 J Our Journey of Dalian Ends 费用流
  4. Javascript class获取回调函数数据
  5. 【leetcode】21-MergeTwoSortedLists
  6. Unity LOD-Level of Detail(多层次细节)用法教程
  7. Gym 102091A: Flying Squirrel(RMQ)
  8. FTP 文件传输协议的两种模式:主动模式和被动模式
  9. ionic1页面间传递参数的问题
  10. MySQL--时间戳属性1