Kathirvel

Hi All,

I came across some weird problem while coding with DataGridView events. I am using Windows forms, .NET 2.0 and DataGridView.

Sample steps to reproduce.

1. One DataGridView and two buttons as OK and Cancel.
2. Create two columns and first column is a DataGridViewCheckBoxColumn and another column is a DataGridViewTextBoxColumn.
3. The second column has the email address validation and only accept valid email address.
4. For email address, i am firing "CELL VALIDATING" event to validate the Cell which is having the email address entered and display in the cell as ERROR TEXT if the email address is invalid.
5. When it is checkbox is checked, i am firing the "CellContentClick" event and make the Email address cell editable and populating the default email address initially i.e Enabled the user to enter the email address also.... Please note that until unless you checked, you can't enter the email address.
6. In OK click, i am checking all the rows whether it has any valid email address i.e whether the email address cell has the ERROR TEXT or not....and if not i will allow further.

7. Everything is working fine except the following TEST CASE SCENARIO...

TEST CASE SCENARIO:

STEPS TO REPRODUCE:

1. I checked the CHECKBOX for the first row, the email address automatically populated in the email address cell. NO PROBLEM HERE...fine.
2. I am selecting the email address and DELETE the whole thing and make the cell as empty.
3. WITHOUT LOST FOCUS ...i am in the same CELL only, and directly i am PRESSING the OK button.
4. I got the Message Box saying "PLEASE CORRECT THE ERROR" (whatever i have implemented, if condition says that if the Error Text exists for the cell..) so the CELL VALIDATING event fired and puts the ERROR TEXT for the corresponding cell..
NO PROBLEM HERE.
5. Now after pressing OK for the MESSAGE BOX and i am going to UNCHECK the Checkbox for the INVALID EMAIL ADDRESS row...which has the error and the cell is empty..as well......<<<<<<<PROBLEM.. HERE>>>>>>>>>

What happens is the CHECK BOX IS NOT UNCHECKED but it implements the logic which i did for the UNCHECK ...i.e ..CELL CONTENT CLICK...i am checking whether check box is checked or not...and if checked i am enabling the EMAIL ADDRESS cell and if unchecked ..i am disabling the email address cell..

So, the email address got DISABLED but THE CHECK BOX IS STILL IN THE STATE (CHECKED STATE).

After if you doing again, THE CHECK BOX IS UNCHECKED and email address cell is ENABLED>>>>>>>>>>>>>>>

<<<<<<<<<<<<<LOGIC REVERSED>>>>>>>>>>>>>>>>>>>>>>>>

Please help me in this regard.

Thanks,
KATHIR



Re: Windows Forms Data Controls and Databinding CHECKBOX Validation Problem : DATAGRIDVIEW

Ken Tucker

Sounds like the cell is not redrawing itself for some reason. Try calling the Datagridview's InvalidateCell method for the checkbox column when you enable or disable the Email Cell.





Re: Windows Forms Data Controls and Databinding CHECKBOX Validation Problem : DATAGRIDVIEW

Kathirvel

Can you please tell me more specific I have gone through the link that u mentioned and i couln't get anything since all in VB.NET and i am working to C#.NET and i felt something i am missing out..

please give me more detaile one.





Re: Windows Forms Data Controls and Databinding CHECKBOX Validation Problem : DATAGRIDVIEW