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);
                    }
                }
  • 相关阅读:
    《研磨设计模式》阅读摘要
    心电图
    nodejs
    自动化测试
    Hook技术
    热修复原理
    理解ClassLoader
    Dalvik和ART
    Java虚拟机
    理解WindowManagerService
  • 原文地址:https://www.cnblogs.com/FLWL/p/4339970.html
Copyright © 2011-2022 走看看