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);
                    }
                }
  • 相关阅读:
    第0次作业
    第4次作业
    第3次作业
    第2次作业
    C#浮点数保留位数
    第0次作业
    软件工程第4次作业
    软件工程第3次作业
    软件工程第2次作业
    软件工程第1次作业
  • 原文地址:https://www.cnblogs.com/FLWL/p/4339970.html
Copyright © 2011-2022 走看看