AD
Administrator
Syncfusion Team
June 16, 2004 02:25 PM UTC
Subscribe to the SelectionsChanging event. In the handler, loop through the rows in e.Range, getting the GridBoundRecordState for each row(grid.Binder.GetRecordStateAtRowIndex). If the recordState.LevelIndex > 0 for any row, then set e.Cancel = true.
LS
Lori S. Pearsall
June 16, 2004 02:50 PM UTC
Here''s an example :
Parent 1 has 2 children & Parent 2 has none
If the user does a multi-select (using the Shift key) of Parent 1 and Parent 2, I would like to remove the two children from the selection. Will setting e.Cancel to true cancel the entire selection? Can I alter e.Range to remove the child rows?
>Subscribe to the SelectionsChanging event. In the handler, loop through the rows in e.Range, getting the GridBoundRecordState for each row(grid.Binder.GetRecordStateAtRowIndex). If the recordState.LevelIndex > 0 for any row, then set e.Cancel = true.
AD
Administrator
Syncfusion Team
June 16, 2004 03:00 PM UTC
No, this SelectionChanging technique will only show parent 1 since as soon as a invalid row is encountered, the selectionchanging stops to selections.
If you want your user to be able to select anything, and then you remove rows you do not want to remain selected, then try the SelectionChanged event, unselecting the rows you do not want to leave selected.
LS
Lori S. Pearsall
June 16, 2004 03:12 PM UTC
Thanks!
One more question ...
If I perform the example above and implement code in the SelectionChanged event to "unselect" the two child rows in the middle, I assume that I''ll have to modify the existing range and add another range since the desired records aren''t consecutive. Will BeginUpdate/EndUpdate be sufficient to suspend additional SelectionChanged events until I''ve performed both actions?
AD
Administrator
Syncfusion Team
June 16, 2004 04:23 PM UTC
No, BeginUpdate & EndUpdate affect only painting, and does not control selection events. You would have to add a flag to your class and use it to indicate when you wanted to avoid your selection code.