BaseView.BeginSelection() Method
Prevents selection updates until the BaseView.EndSelection or the BaseView.CancelSelection method is called.
Namespace: DevExpress.XtraGrid.Views.Base
Assembly: DevExpress.XtraGrid.v24.1.dll
NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation
Declaration
Remarks
The BeginSelection method, paired with the BaseView.EndSelection/BaseView.CancelSelection method, allows you to improve the grid performance when successively selecting a batch of rows/cells in code. See the Multiple Row and Cell Selection topic, to learn about the methods to select and unselect rows and cells.
If not using the BeginSelection method, the View is updated and the ColumnView.SelectionChanged event fires after every single selection modification. The BeginSelection method, when called prior to changing the selection in code, suspends selection updates until the BaseView.EndSelection or BaseView.CancelSelection method is called.
The EndSelection and CancelSelection methods enable future selection updates, but unlike CancelSelection, the EndSelection method forces an immediate visual update and fires the ColumnView.SelectionChanged event.
Note
Each call of the BeginSelection method must correspond to a call of the BaseView.EndSelection or the BaseView.CancelSelection method. To ensure that BaseView.EndSelection or BaseView.CancelSelection is always called even if an exception occurs, use the try…finally statement.
Refer to the Multiple Row and Cell Selection document for more information on row selection. The Batch Modifications Overview topic provides more details on batch modifications.
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the BeginSelection() method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.