返回首页

嗨,

我使用C#。NET开发Windows应用程序......在这,我有一个DataGridView的DataGridViewCheckBoxColumn的(checkbox1,checkbox2,checkbox3)..

在这里我想取消的remainining 2 colums而我检查一个特定的列......例如,第一,我检查checkbox1我改变检查checkbox2,那个时候我需要自动取消选中checkbox1列,反之亦然........

帮我出家伙!!!!!

回答

评论会员:游客 时间:2012/02/04
点击控制CheckedChanged事件,你还可以得到当前行的点击控制,也可以找到同一行的剩余控制
Nathansathya:我终于解决方案为这个......

下面的代码,写上CellValidating事件

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;

                    }

                }

            }

重复代码的其余列........
评论会员:萨拉SS 时间:2012/02/04
的DataTable DT =新的DataTable()的foreach(DataRow中排在dt.Rows)

{
(行["gridviewcheckboxcolumnname"] =="真"的ToString())
{
NBSP / /您的代码
}
}