Articles in this section

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

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 the Cancel property.


// 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;
}
'Trigger the required event.
AddHandler Me.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

The screenshot below shows the holding of row selection 


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)
Access denied
Access denied