Hi,
I have an UltraGrid which contains a few buttons. I want to select multiple rowns in the grid and then click the button from one of the rows (here the Selected.Rows.Count = number of rows seelcted). However, in the ClickCellButton method I see that the
Selected.Rows.Count gets set to zero. Is there any way in which I can retain the row selection on button click.
Thanks,
Ketaki
Dear Brian
I'm having the same issue.When I try to implement MultiSelect combined with a CellButtonClick it simply clears the Selected.Rows before I can access them.The workaround with AfterSelectChange also didn't work.
The MousClick-Event is not an option. If I press Shift and arrow key down, I can also select rows (which would be ignored).
Note: I'm using Infragistics 2010.3.
Kind RegardsFabian
This happens because all selections are cleared when a cell enters edit mode. It is difficult to work around this because at the time the BeforeEnterEditMode event fires, the selection has already been cleared, so you can't cache it therein. Furthermore, when the Before/AfterSelectChange events fires, no context is given in the event arguments to indicate that reason the selection is changing, so while you can cache the selection therein, you don't have a cue by which to know whether to ignore that firing.
I vaguely remember hacking around this once but it was messy; I had to do something like handle MouseDown and set a flag to see if that MouseDown triggered both a selection change and an edit mode session, in which case you *assumed* than the selection was changed because of an edit mode session beginning (I don't necessarily recommend you do this).
The best solution to the problem would be freedom of control over whether selection is cleared when an edit mode session begins, or a property added to the BeforeSelectChangeEventArgs class that gives you the reason the event fired, one of the reasons being that an edit mode session is beginning. You might want to log a feature request for this.
You can simulate that. Handle the AfterSelectChange event and save the selected rows in a class member:
selectedRows = grid.Selected.Rows.OfType<UltraGridRow>();
When the user clicks the button, select all previously selected rows:
grid.Selected.Rows.AddRange(selectedRows.ToArray())