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

winfrom 中datagridview中checkbox的使用方法

时间:2014-08-16 19:39:00      阅读:299      评论:0      收藏:0      [点我收藏+]

标签:datagridview   blog   http   使用   os   ar   2014   div   

   private void dgdv_skjs_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex != -1)
            {
                DataGridViewCheckBoxCell checkCell_rxwk = (DataGridViewCheckBoxCell)dgdv_skjs.Rows[e.RowIndex].Cells["rxwk"];
                DataGridViewCheckBoxCell checkCell_bx = (DataGridViewCheckBoxCell)dgdv_skjs.Rows[e.RowIndex].Cells["bx"];
                bool rxwk = Convert.ToBoolean(checkCell_rxwk.Value.ToString());
                bool bx = Convert.ToBoolean(checkCell_bx.Value.ToString());
                if (e.ColumnIndex == 3 )
                {
                    if (rxwk == false && bx == true)
                    {
                        checkCell_rxwk.Value = true;
                        checkCell_bx.Value = false;

                    }
                    else if (rxwk == false && bx == false)
                    {
                        checkCell_rxwk.Value = true;
                        checkCell_bx.Value = false;
                    }
                    else if (rxwk == true && bx == false)
                    {
                        checkCell_rxwk.Value = false;
                        checkCell_bx.Value = false;
                    }
                    else
                    { }
                }
                else if (e.ColumnIndex == 4)
                {
                    if (rxwk == true && bx == false)
                    {
                        checkCell_rxwk.Value = false;
                        checkCell_bx.Value = true;
                    }
                    else if (rxwk == false && bx == false)
                    {
                        checkCell_rxwk.Value = false;
                        checkCell_bx.Value = true;
                    }
                    else if (rxwk == false && bx == true)
                    {
                        checkCell_rxwk.Value = false;
                        checkCell_bx.Value = false;
                    }
                    else
                    { }
                }
                else
                {
                }
            }
        }

效果图如下:
bubuko.com,布布扣

winfrom 中datagridview中checkbox的使用方法,布布扣,bubuko.com

winfrom 中datagridview中checkbox的使用方法

标签:datagridview   blog   http   使用   os   ar   2014   div   

原文地址:http://www.cnblogs.com/Small-Life/p/3916771.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!