zoukankan      html  css  js  c++  java
  • C# Windows DataGridView 判断CheckBox 选取的方法

    单行选中

    foreach (DataGridViewRow dr in this.dataGridView1.Rows)
                {
                    try
                    {
                        //DataGridViewCheckBoxCell cbx = (DataGridViewCheckBoxCell)dr.Cells[0];
                        //if ((bool)cbx.FormattedValue)
                        if(dr.Cells[0].Selected)
                        {
                            arrShiftCode.Add(dr.Cells[1].Value);
                            arrShiftGroup.Add(dr.Cells[2].Value);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

    复制代码
    多行选中
    foreach (DataGridViewRow dr in this.dataGridView1.Rows)
                {
                    try
                    {
                        DataGridViewCheckBoxCell cbx = (DataGridViewCheckBoxCell)dr.Cells[0];
                        if ((bool)cbx.FormattedValue)
                        {
                            arrShiftCode.Add(dr.Cells[1].Value);
                            arrShiftGroup.Add(dr.Cells[2].Value);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
  • 相关阅读:
    Ajax调用WCF报405错误
    字符串转json方法
    正则取括号里面的内容
    string[] 转int[] 的方法
    C# 中结构与类的区别
    通用的权限模块是如何设计的?
    .net打包自动安装数据库!
    VS.net 2005快捷键一览表
    Windows Forms DataGridView 中合并单元格
    VS2005 制作安装程序
  • 原文地址:https://www.cnblogs.com/FLWL/p/4339970.html
Copyright © 2011-2022 走看看