zoukankan      html  css  js  c++  java
  • winfrom 中datagridview中checkbox的使用方法

       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
                    {
                    }
                }
            }
    

    效果图如下:

  • 相关阅读:
    node爬取html乱码
    mysql字段有中英文,数字按照升序/降序 排序
    解决git反复输入密码的问题
    vue在jsx中使用for循环
    vscode插件篇
    table无法控制宽度
    console输出彩色字体
    原生js实现vue组件功能
    ES6中的proxy
    面向对象编程
  • 原文地址:https://www.cnblogs.com/Small-Life/p/3916771.html
Copyright © 2011-2022 走看看