Articles in this section
Category / Section

How to prevent the cell or column from being a part of the selection in WinForms GridControl?

1 min read

Prevent the grid cell or column

In GridControl, you can use the grid’s SelectionChanging event to cancel a selection depending upon the criteria that you have specified.

C#

void gridControl1_SelectionChanging(object sender, GridSelectionChangingEventArgs e)
{
   //prevent cell from selection
   if(e.Range.Contains(GridRangeInfo.Cell(2,2)))
     e.Cancel=true;
   //prevent column from selection
   if(e.Range.IntersectsWith(GridRangeInfo.Col(3)))
     e.Cancel=true;
}

 

VB

Private Sub gridControl1_SelectionChanging(ByVal sender As Object, ByVal e As GridSelectionChangingEventArgs)
   'prevent cell from selection
   If e.Range.Contains(GridRangeInfo.Cell(2,2)) Then
     e.Cancel=True
   End If
   'prevent column from selection
   If e.Range.IntersectsWith(GridRangeInfo.Col(3)) Then
     e.Cancel=True
   End If
End Sub

 

Samples:

C#: Prevent the cell for part of the selection

VB: Prevent the cell for part of the selection

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