实现DataGridView控件中CheckBox列的使用
2014-01-20 11:56
429 查看
最近做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 {
if ((bool)dgvTradList.Rows[e.RowIndex].Cells[0].EditedFormattedValue == true)
{
dgvTradList.Rows[e.RowIndex].Cells[0].Value = false;
}
else
{
dgvTradList.Rows[e.RowIndex].Cells[0].Value = true;
}
}
19 }
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 {
if ((bool)dgvTradList.Rows[e.RowIndex].Cells[0].EditedFormattedValue == true)
{
dgvTradList.Rows[e.RowIndex].Cells[0].Value = false;
}
else
{
dgvTradList.Rows[e.RowIndex].Cells[0].Value = true;
}
}
19 }
相关文章推荐
- 实现DataGridView控件中CheckBox列的使用实例
- 实现DataGridView控件中CheckBox列的使用实例
- 原创 c# 封装的带CheckBox的DataGridViewColumnHeaderCell 源码部分 实现DataGridView列头带CheckBox控件实现全选功能,支持列头带标题
- 在C#中使用控件DataGridView实现数据库增删改查
- DataGridView控件中CheckBox列的使用
- 使用onpropertychange,实现树控件的递归级自动触发,保证全选的正确性。(checkBox)
- 在C#中使用控件DataGridView实现数据库增删改查
- Asp.net 中使用GridView控件实现Checkbox单选
- 使用CheckBox控件实现全选与全不选
- 使用CheckBox控件实现同意条款效果
- 使用Jquery X-Menu 插件实现多选checkbox控件的功能
- C#2005中使用控件DataGridView实现对数据库增删改查操作
- 在C#中使用控件DataGridView实现数据库增删改查
- 使用masterpage的情况下如何使用js实现repeater控件里的checkbox全选
- 在C#中使用控件DataGridView实现数据库增删改查
- 使用CheckBox控件实现全选与全不选
- DataGridView使用DataGridViewCheckBoxColumn实现RadioBox单选功能
- winform中DataGridView使用DataGridViewCheckBoxColumn实现RadioBox单选功能
- 在C#中使用控件DataGridView实现数据库增删改查
- C#2005中使用控件DataGridView实现对数据库增删改查操作