C# 获取点击列的索引
2024-09-06 11:34:41
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;
最新文章
- Java学习笔记:控制反转
- 浅谈python web框架中的orm设计
- 看了一本Unity3D的教程
- gpart 使用笔记
- faker image
- [反汇编练习] 160个CrackMe之022
- Anroid之Intent的使用
- 基于ViewPager的一些酷炫切换效果
- ES6走一波 Generator异步应用
- OCM_第十七天课程:Section7 —》GI 及 ASM 安装配置 _管理和配置 GRID /实施 ASM 故障组 /创建 ACFS 文件系统
- Php 通过curl提交post内容为 Json的请求
- mysql优化(二)
- 迷宫最短路径问题的dfs,bfs实现
- group by 和count的联合使用问题 [转]
- wpgcms---单片页数据渲染
- 在有 UI 线程参与的同步锁(如 AutoResetEvent)内部使用 await 可能导致死锁
- Android 当修改一些代码时,使用什么编译命令可以最有效率
- echarts报表
- PAT 1096 Consecutive Factors[难]
- 【python】判断字符串以什么开头或结尾
热门文章
- Java基础:抽象类和接口
- Can&;#39;t open named pipe to host: . pipe: MySQL
- Django中的模板和分页
- openwrt 修改 banner
- 启动app-inspector报Internal Server Error
- Cocos2d-x之LayerMultiplex的使用
- PowerDesigner逆向工程,从SQL Server数据库生成Physical Model -----数据源方式
- Java中实现函数的阻塞
- Struts2中的redirect参数传递
- Struts2页面遍历