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);
                    }
                }
  • 相关阅读:
    C&C++ recap
    将Rmarkdown文件转为pdf文件
    ChIP-seq Peak caller MACS index out of range问题解决
    R正则表达式的问题
    nodejs+cheerio爬虫测试
    jetty更换图标
    MyEclipse无法生成class文件
    JPA @OneToOne stackoverflow
    jquery-validate--使用由于疏忽导致的问题1(input失去焦点没有被验证,submit才验证)
    组合框
  • 原文地址:https://www.cnblogs.com/FLWL/p/4339970.html
Copyright © 2011-2022 走看看