问题描述
大家好,
我正在使用C#.net开发Windows应用程序...我有一个带3个DataGridViewCheckBoxColumn(checkbox1,checkbox2,checkbox3)的datagridview..
在这里,我想取消选中剩下的2列,而我又选中了一个特定的列..例如,第一,我选中checkbox1,然后更改为checkbox2,那时候我需要自动取消选中checkbox1列,反之亦然.....
帮帮我吧!!!!!!!!!
Hi Guys,
I am developing windows application using C#.net...In that I have one datagridview with 3 DataGridViewCheckBoxColumn (checkbox1,checkbox2,checkbox3)..
here i want to uncheck the remainining 2 colums while i checked one particular column..for eg,1st i check checkbox1 and i change to check checkbox2,that time i need to uncheck checkbox1 column automatically and viceversa........
Help me out guys!!!!!!!!!
推荐答案
int column = e.ColumnIndex;
int row = e.RowIndex;
if (column == 2)
{
DataGridViewCheckBoxCell c = dgv1[e.ColumnIndex, e.RowIndex] as DataGridViewCheckBoxCell;
if (c != null)
{
string a = e.FormattedValue.ToString();
if (a == "True")
{
dgv1.Rows[row].Cells["column2"].Value = false;
dgv1.Rows[row].Cells["column3"].Value = false;
}
else
{
dgv1.Rows[row].Cells["column1"].Value = false;
dgv1.Rows[row].Cells["column2"].Value = false;
dgv1.Rows[row].Cells["column3"].Value = false;
}
}
}
重复其余列的代码........
repeat the code for remaining columns........
这篇关于在C#.net中检查DataGridViewCheckBoxColumn的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!