Articles in this section
Category / Section

How to hold the row selection after the cell is deactivated in WinForms GridControl?

1 min read

Hold the row selection

In order to hold the row selection after the cell is deactivated, the SelectionChanging event can be used. The selection can be canceled by using Cancel property.

C#

// form()
// Trigger the required event.
gridControl1.Model.SelectionChanging += Model_SelectionChanging;
 
void Model_SelectionChanging(object sender, GridSelectionChangingEventArgs e)
{
   if (e.Reason == GridSelectionReason.MouseDown || e.Reason == GridSelectionReason.Clear)
      e.Cancel = true;
}

 

VB

' form()
' Trigger the required event.
Private gridControl1.Model.SelectionChanging += AddressOf Model_SelectionChanging
 
Private Sub Model_SelectionChanging(ByVal sender As Object, ByVal e As GridSelectionChangingEventArgs)
   If e.Reason = GridSelectionReason.MouseDown OrElse e.Reason = GridSelectionReason.Clear Then
   e.Cancel = True
   End If
End Sub

 

Screenshot

Showing hold the row selection in grid

Sample links:

C# HoldingRowSelection_CS

VB HoldingRowSelection_VB

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied