Skip to content

Issue with check box behaviour in datagridview in c#.

sanjeeva kalakuntla

Asked Apr 1, 2013, 9:56 PM EDT1 answer
Share
LinkedInX
I have a problem with the check box.I am using check box with the datagridview in windows forms in c#. when I check and uncheck the check box quickly( less than a sec),it is taking as checked.please help me
 
this is what i tried


if (e.ColumnIndex == dgCategoryView.Columns["chkSelectCategory"].Index&&e.RowIndex>=0) {
DataGridViewCheckBoxCell ch1 = new DataGridViewCheckBoxCell();
ch1=(DataGridViewCheckBoxCell)dgCategoryView.Rows[dgCategoryView.CurrentRow.Index].Cells[0]; if (ch1.Value == null)
ch1.Value = false;
 switch (ch1.Value.ToString())
{
case "True":
for (int i = 0; i < Categoryrowlist.Count; i++)
{
 if (Categoryrowlist[i] == categoryList[e.RowIndex + currentC].Id)
{
Categoryrowlist.Remove(Categoryrowlist[i]);
 }
 }
 ch1.Value = false;
break;
case "False":
Categoryrowlist.Add(categoryList[e.RowIndex + currentC].Id);
 ch1.Value = true;
break;
}
}

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    My small suggestion. As soon as the user clicks the control, just disable it and do run your custom code..... Etc. once you're done, enable the control back.
    0