Results 1 to 3 of 3

Thread: [RESOLVED] manipulate 2 Checkboxes in DataGridView at the same time

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    589

    Resolved [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 !!!
    Last edited by tutus; Mar 9th, 2010 at 04:29 PM.
    Thanks a lot for your help.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    589

    Re: manipulate 2 Checkboxes in DataGridView at the same time

    Quote Originally Posted by tutus View Post
    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....
    Thanks a lot for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width