windowsforms-devexpress-dot-xtragrid-dot-views-dot-base-dot-baseview-892aec41.md
Prevents selection updates until the BaseView.EndSelection or the BaseView.CancelSelection method is called.
Namespace : DevExpress.XtraGrid.Views.Base
Assembly : DevExpress.XtraGrid.v25.2.dll
NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation
public virtual void BeginSelection()
Public Overridable Sub BeginSelection
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.
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.
winforms-preserve-grid-state-on-refresh/CS/RefreshHelperClass.cs#L136
public void LoadSelectionViewInfo(ArrayList list) {
view.BeginSelection();
try {
winforms-gridlookupedit-multiple-item-selection/CS/Form1.cs#L84
private void UpdateSelection(PopupContainerEdit edit, GridView view) {
view.BeginSelection();
view.ClearSelection();
winforms-grid-select-rows-with-mouse/CS/WindowsApplication1/Form1.cs#L31
{
view.BeginSelection();
view.ClearSelection();
winforms-preserve-grid-state-on-refresh/VB/RefreshHelperClass.vb#L145
Public Sub LoadSelectionViewInfo(ByVal list As ArrayList)
view.BeginSelection()
Try
winforms-gridlookupedit-multiple-item-selection/VB/Form1.vb#L79
Private Sub UpdateSelection(ByVal edit As PopupContainerEdit, ByVal view As GridView)
view.BeginSelection()
view.ClearSelection()
winforms-grid-select-rows-with-mouse/VB/WindowsApplication1/Form1.vb#L25
If startRow > -1 AndAlso endRow > -1 Then
view.BeginSelection()
view.ClearSelection()
See Also