datagridview 怎么获取选中行的某一列的索引
比如 下面是表
学号 姓名 所在年级
 1    张     高一
 2    李     高二
当我选择第二行的时候 我想取所在年级的列索引 这时候那个列索引应该是3 我怎么取得呢 谢谢大家

------解决方案--------------------
假如那列的name是 xxx,
dataGridView1.CurrentRow.Cells["xxx"].ColumnIndex
------解决方案--------------------
DataGridViewRow row = this.dataGridView1.CurrentRow;//当前行
object value = row.Cells[列索引或列名];
------解决方案--------------------
当前行指定列的索引
dataGridView1.CurrentRow.Cells["所在年级"].ColumnIndex  // 3

当前行索引
dataGridView1.CurrentRow.Index  // 1 (第二行)

当前单元格的行索引

dataGridView1.CurrentCell.RowIndex

RadGridView单元格的列索引
int columnIndex = rg.CurrentCell.Column.DisplayIndex;

最新文章

  1. Java学习笔记:控制反转
  2. 浅谈python web框架中的orm设计
  3. 看了一本Unity3D的教程
  4. gpart 使用笔记
  5. faker image
  6. [反汇编练习] 160个CrackMe之022
  7. Anroid之Intent的使用
  8. 基于ViewPager的一些酷炫切换效果
  9. ES6走一波 Generator异步应用
  10. OCM_第十七天课程:Section7 —》GI 及 ASM 安装配置 _管理和配置 GRID /实施 ASM 故障组 /创建 ACFS 文件系统
  11. Php 通过curl提交post内容为 Json的请求
  12. mysql优化(二)
  13. 迷宫最短路径问题的dfs,bfs实现
  14. group by 和count的联合使用问题 [转]
  15. wpgcms---单片页数据渲染
  16. 在有 UI 线程参与的同步锁(如 AutoResetEvent)内部使用 await 可能导致死锁
  17. Android 当修改一些代码时,使用什么编译命令可以最有效率
  18. echarts报表
  19. PAT 1096 Consecutive Factors[难]
  20. 【python】判断字符串以什么开头或结尾

热门文章

  1. Java基础:抽象类和接口
  2. Can't open named pipe to host: . pipe: MySQL
  3. Django中的模板和分页
  4. openwrt 修改 banner
  5. 启动app-inspector报Internal Server Error
  6. Cocos2d-x之LayerMultiplex的使用
  7. PowerDesigner逆向工程,从SQL Server数据库生成Physical Model -----数据源方式
  8. Java中实现函数的阻塞
  9. Struts2中的redirect参数传递
  10. Struts2页面遍历