Hi,
I have a check box column. I would like to select the rows when the user clicks on the checkbox.
Currently the rows are not gettting selected on when checkbox is checked. How to select multiple rows programmatically.
thanks,
I don't see any way to do this. The problem is that as soon as a cell enters edit mode, all previous selected rows are unselected. There's no way around this. Or at least no simple way.
One way you could acheive this is to turn off selection of rows in the grid and then handle the selection yourself. Basically, this would mean handling the MouseDown event and keeping your own list of "selected" rows. Then you could use the InitializeRow event to apply an appearance to those rows so they appear selected to the user. This way, when the user edits a cell, you simply don't clear the selection. But you would essentially have to re-implement all of the selection logic you need like dragging across rows, range selection, non-contguous selection, etc.
Ah I meant something slightly different. What I mean is I would like a work-around that means putting a cell in Edit mode implies that its ROW is in SelectedRows. If you multiple selected something, nothing would be in edit mode, but if you then entered edit mode, the selected rows would change to include only the currently editable cell's row.
Is that something that's possible? Or do I have to track changes to the SelectedRows and Editable cell myself?
This is pretty much the way it works with all Windows applications and controls that I know of. Selecting multiple rows and editing an individual item are mutually exclusive.
The easiest thing to do would be to use something else for "selected". Like, for example, you could use an unbound CheckBox column in the grid. That way, the checked columns would not be affected by editing a cell.
Mike, is there a work around that is used for this? It doesn't make sense to me that enter a edit mode on a cell would change the selected row? For example, if I edit a cell in the currently selected row, the row should remain selected. If I enter edit more on a cell in a different row, THAT row should become the selected row.
This makes it much easier to handle keyboard-style navigation - e.g. - while editing a cell, the user can type Alt-X to execute without having to leave the cell and re-select the row by clicking on some non-editable cell.
Hi Swati,
The easiest thing for you to do would be to try it out and see if it works. But I don't think it will. You cannot have selected rows and also edit a cell at the same time. Once a cell enters edit mode, then you will lose the selected rows. So you can click a CheckBox and select the row, but as soon as you click any other cell that goes into edit mode, including any other checkbox cell, the previously selected row will be de-selected.