首页 > Windows开发 > 详细

实现DataGridView控件中CheckBox列的使用

时间:2014-01-20 19:32:25      阅读:389      评论:0      收藏:0      [点我收藏+]

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

bubuko.com,布布扣
 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             }
bubuko.com,布布扣

19         } 

实现DataGridView控件中CheckBox列的使用

原文:http://www.cnblogs.com/weixiao520/p/3526704.html

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