We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GridHierarchyLevel & selecting rows

Thread ID:

Created:

Updated:

Platform:

Replies:

15340 Jun 16,2004 02:20 PM UTC Jun 16,2004 04:23 PM UTC Windows Forms 5
loading
Tags: GridControl
Lori S. Pearsall
Asked On June 16, 2004 02:20 PM UTC

I have a grid that has multi-selection turned on. It also has a single GridHierarchyLevel. Is there any way that I can prevent the user from selecting child rows?

Administrator [Syncfusion]
Replied On 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.

Lori S. Pearsall
Replied On 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.

Administrator [Syncfusion]
Replied On 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.

Lori S. Pearsall
Replied On 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?

Administrator [Syncfusion]
Replied On 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.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;