zoukankan      html  css  js  c++  java
  • C# 获取点击列的索引

    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;

  • 相关阅读:
    django 单表操作
    爬虫学习
    DRF源码分析
    DRF权限和频率限制
    DRF版本和认证源码分析
    request高级部分
    多任务异步爬虫及selenium模块使用
    requests基本使用
    爬虫介绍及环境
    Flask生命周期的源码流程
  • 原文地址:https://www.cnblogs.com/yisheng/p/3860525.html
Copyright © 2011-2022 走看看