[RESOLVED] manipulate 2 Checkboxes in DataGridView at the same time
Hi,
.Net 3.5
I have 2 columns in a datagridview bound to datasource. When the user checks off one checkbox, i want to check some business logic after which I set the 2nd check box in the same row as checked as well.
My problem is: I want to check the 2nd check box right after the user clicks on the first checkbox and not only after he tabs away by clicking somewhere else.
Right now, I only succeed runing my business logic in the CellValueChanged or CellParsing events but those only occur after the user leaves the checkbox, which is not desired, I d like to run the logic and show the 2nd checkbox checked right after the user clicks on the 1st checkbox.
I also tried: CellClick event but I don t know how to : when the user clicks on a a checkbox, how to change the value of other checkboxes in the current row during CellClick event . The changes does not take effect in the UI !!!
Re: manipulate 2 Checkboxes in DataGridView at the same time
Try the CellContentClick event. Mind you, if the cell Value doesn't change when you click the content, I'm not sure what help that will be.
Re: manipulate 2 Checkboxes in DataGridView at the same time
Quote:
Originally Posted by
tutus
Hi,
.Net 3.5
I have 2 columns in a datagridview bound to datasource. When the user checks off one checkbox, i want to check some business logic after which I set the 2nd check box in the same row as checked as well.
My problem is: I want to check the 2nd check box right after the user clicks on the first checkbox and not only after he tabs away by clicking somewhere else.
Right now, I only succeed runing my business logic in the CellValueChanged or CellParsing events but those only occur after the user leaves the checkbox, which is not desired, I d like to run the logic and show the 2nd checkbox checked right after the user clicks on the 1st checkbox.
I also tried: CellClick event but I don t know how to : when the user clicks on a a checkbox, how to change the value of other checkboxes in the current row during CellClick event . The changes does not take effect in the UI !!!
Just to let you know, I am using Parse events in my grid since the underlying object uses the values 33/34 instead of true/false, so I use Formatting/Parsing events to transform the 33/34 to true/false values for my checkbox columns.
Anyway here is how a colleague helped me solve the pb:
I use the event: CurrentCellDirtyStateChanged which fires right after the 1st checkbox is cliked, in it I use commit which means the parsing/valuechanged events fires right away instead of waiting for the user to tab away from the clicked checkbox. And in those events I can set/unset the 2nd checkbox as I wish. The whole stuff renders in the UI before the user tabs away from the 1st clicked checkbox.
Thanks to everyone and to jmcilhinney.... :)