码迷,mamicode.com
首页 > Windows程序 > 详细

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

时间:2015-03-15 18:06:38      阅读:236      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!