zoukankan      html  css  js  c++  java
  • 实现DataGridView控件中CheckBox列的使用

    最近做WindowsForms程序,使用DataGridView控件时,加了一列做选择用,发现CheckBox不能选中。搜索后,要实现DataGridView的CellContentClick事件,将代码贴一下:

     1         /// <summary>
     2         /// 实现DataGridView控件中CheckBox列的使用
     3         /// </summary>
     4         /// <param name="sender"></param>
     5         /// <param name="e"></param>
     6         private void dgvTradList_CellContentClick(object sender, DataGridViewCellEventArgs e)
     7         {
     8             if (e.ColumnIndex == 0 && e.RowIndex != -1)
     9             {
    10                 if ((bool)dgvTradList.Rows[e.RowIndex].Cells[0].EditedFormattedValue == true)
    11                 {
    12                     dgvTradList.Rows[e.RowIndex].Cells[0].Value = false;
    13                 }
    14                 else
    15                 {
    16                     dgvTradList.Rows[e.RowIndex].Cells[0].Value = true;
    17                 }
    18             }

    19         } 

  • 相关阅读:
    正则表达式
    Newtonsoft.Json
    MVC之参数验证(三)
    MVC之参数验证(二)
    MVC之参数验证(一)
    MVC之模型绑定
    导致存储过程重新编译的原因
    IFormattable,ICustomFormatter, IFormatProvider接口
    oracle将id串转换为名字串
    oracle查看表空间大小及使用情况
  • 原文地址:https://www.cnblogs.com/weixiao520/p/3526704.html
Copyright © 2011-2022 走看看