首页 > Windows开发 > 详细

C# Windows DataGridView 判断CheckBox 选取的方法

时间:2015-03-15 18:06:33      阅读:429      评论:0      收藏:0      [点我收藏+]

单行选中

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# Windows DataGridView 判断CheckBox 选取的方法

原文:http://www.cnblogs.com/FLWL/p/4339970.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!