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);
                    }
                }
  • 相关阅读:
    Qt 数据库篇
    js字符串函数(转)
    如何解决IE无法识别html5中的新标签(article、abbr、header等)
    web多页打印问题
    诡异的Spinner级联样式
    discuz x2用户删除了,帖子不能用了,恢复帖子的办法
    创业公司如何招聘优秀工程师
    清除目录下的SVN信息
    .NET 项目SVN 全局排除设置
    编程技术面试的五大要点
  • 原文地址:https://www.cnblogs.com/FLWL/p/4339970.html
Copyright © 2011-2022 走看看