-
Oct 6th, 2017, 03:14 AM
#1
Thread Starter
Addicted Member
-
Oct 6th, 2017, 03:52 AM
#2
Re: multiselect cells in a datagridview and set value's of checkboxes
Firstly, this:
vb.net Code:
If CBool(selectedCell.Value) = True Then selectedCell.Value = False ElseIf CBool(selectedCell.Value) = False Then selectedCell.Value = True End If
is an extremely verbose way to toggle a Boolean. All you need is this:
vb.net Code:
selectedCell.Value = Not CBool(selectedCell.Value)
As for your issue, it doesn't seem appropriate to toggling check boxes in the SelectionChanged event handler. Think about what is going to happen. Let's say that you have every box unchecked initially. When you select the first cell, that box will be checked. When you select the second cell, the event is raised again so the new cell will be checked but the first one will be unchecked. When you select the third cell, it will be checked, the second one will be unchecked and the first will be checked again. It doesn't make sense to be making changes as you select. You should select all the cells you want to toggle first, then click a Button to toggle them all.
-
Oct 6th, 2017, 04:01 AM
#3
Thread Starter
Addicted Member
Re: multiselect cells in a datagridview and set value's of checkboxes
Yes you are right was thinking allready that it is checking all selected cells again, but i would like to make it without having to click a button, could do it in a mouse click offcourse
-
Oct 6th, 2017, 04:16 AM
#4
Re: multiselect cells in a datagridview and set value's of checkboxes
You can't do it without a Button or something similar. We've already established that you can't toggle the cells as you select them; you have to wait until you've selected them all first. How is your software supposed to know that you've finished selecting? It can't read your mind so you need to perform some action, e.g. clicking a Button. You could potentially use a Timer and do it automatically when a certain amount of time passes after the last selection change but you'd have to make that time long enough to accommodate slow people and that would annoy fast people who would then have to wait.
-
Oct 6th, 2017, 04:22 AM
#5
Thread Starter
Addicted Member
Re: multiselect cells in a datagridview and set value's of checkboxes
Like said i put it in mouseclick event, click select and let go and it is setting to true where is false and vice versa
have not seen any strange things yet so it is working as i can see now.
Thanks for the guidance
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|