I've got a grid with column of checkboxes not bound to anything. When a range of checkboxes needs to be clicked, instead of having to click them one by one, I'd like to provide Windows like behavior with a Shift-Click like ability. Like use of Up,Down,Ctrl,Home,End would be nice too but just Shift-Click would be better than nothing. I haven't found some inherent setting to make any of this happen.
I haven't even been able to check whether or not Shift or ShiftKey is pressed from CellChange yet whereas it'd be easy from KeyDown or KeyUp which aren't used here.
Hi,
I'm a little fuzzy on exactly what you want to do here. How do you determine the range of checkboxes that need to be checked or unchecked? So you mean you want ALL of them checked?
You would have to use KeyUp or KeyDown to trap for the shift key. CellChange can't provide any key information, because the cell change could occur from something that has nothing to do with the keyboard. You could, for example, click a context menu with the mouse to paste into a cell.
I know there static method in DotNet to determine the current state of the MouseButtons at any given time. So I wonder if there might be similar methods for the key states. If so, I don't know what they are, but it might be worth looking into. Perhaps a Microsoft forum or a general DotNet programming forum might be a good place to post the question. Or you could try searching MSDN or the web. :)
Thanks for the reply.
So I've got a column of unchecked checkboxes in a grid of data. Let's say the user wanted to check the 6th through the 23rd boxes. What's the best way to provide a Windows like ability to click the 6th box, then hold down a Shift key, and click the 23rd box, checking all boxes in that range?
I'll give key state methods research. I've definitely searched the web but might post to MSDN like you said.
Well, typically, a Windows application would not behave as you describe. In any application I know of, selecting the 6th cell, holding down shift, and then clicking the 23rd cell would select the cells. By select, I mean the cells would be highlighted. This would not generally affect the Checked state of the cell.
Although, now that I think about it, I guess some of the reference selection lists in Visual Studio do this when you select rows. I'm not really sure off the top of my head exactly what the behavior should be here, I'd have to do some reseach and maybe use the References list in VS as a reference.
You could set up the grid to allow selecting rows or cells using the SelectTypeRow and SelectTypeCell properties. Then handle the SelectionChanged event of the grid and use that to change the values of the selected rows/cells. You will probably also need to handle KeyUp so that the checkbox are toggled when user presses the space bar and some rows/cells are selected.
I don't mean to hijack the thread, but I have a similar question, so hopefully it's not too far off the OP's topic...
In my case, I do want to select ALL of the checkboxes in an unbound column that contains a checkbox style.
I have a button "Select All" on my form, that when clicked, I would like to mark all the checkboxes as 'checked'. The column containing the checkboxes is in band(2) if that matters.
Thanks!
To check ALL the rows in the band, you would have to loop. The fact that it's a child band does matter, because you will have to loop through multiple rows collections. You could do this recursively, but there is an easier way using the grid.Rows.GetRowsEnumerator method. This method will allow you to loop through all the rows in a specific band.
As you loop, you just set the Value on the checkbox cell.
please clearly tell how to make all checkbox as default false
and if user want to click on it can be changed to false or true.
thanks
(I sometime hate to use infragistics component)
You might also look at the event manager and set the changedcell event to false when the user clicks the cell. Just don't forget to set it back to true.
If you're using the CellChange event, the Value will not have been updated at this point yet. You could either try to convert the Text of the cell to a boolean, or you could look at the value of the editor, assuming that the cell is still in edit mode.
-Matt
I have ultrawingrid and I added an unbound column as checkbox
to make the value of checkbox as default to false I did it in IntializeRowEvent, which all checkbox is false;
but when user want to check one of the checkbox, it doenst change from false to true, I used CellChangeEvent and I did as follow:
{
}
else
I put a debugpoint in cellChangeEvent and I notice after cellchangeEvent it goes back to InitilaizeRow and change it to false again
Then I added a boolean variable "isChecked" and as default is false.But when it comes to cellchangeEvent it changed it to true and I checked in InitializeEvent if it true, do nothing...
I feel this is not right way, is there better way?
Waisted time to debug, but not find an answer. Finally I restarted the computer and it work. Don't know why?