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;

posted on 2014-07-22 14:34  莫等闲也  阅读(887)  评论(0编辑  收藏  举报