How to disable context menu for vertical scrollbar in WinForms GridControl?
Disable the
ContextMenu
In WinForms GridControl, you can disable the context menu for the scroll bar by cancelling the showContextMenu. Here,the context menu is handled by comparing the width of the ClientRectangle and the width of the mouse pointer for the vertical scroll bar.
this.gridControl1.ShowContextMenu += gridControl1_ShowContextMenu;
void gridControl1_ShowContextMenu(object sender, Syncfusion.Windows.Forms.ShowContextMenuEventArgs e)
{
Point c = this.gridControl1.GridPointToClient(e.Point);
//Comparing the point for vertical scroll bar
if (this.gridControl1.ClientRectangle.Width < c.X)
{
//context menu has been handled
e.Cancel = true;
}
}
AddHandler Me.gridControl1.ShowContextMenu, AddressOf gridControl1_ShowContextMenu
Private Sub gridControl1_ShowContextMenu(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.ShowContextMenuEventArgs)
Dim c As Point = Me.gridControl1.GridPointToClient(e.Point)
'Comparing the point for vertical scroll bar
If Me.gridControl1.ClientRectangle.Width < c.X Then
'context menu has been handled
e.Cancel = True
End If
End Sub
Conclusion
I hope you enjoyed learning how to disable the context menu for the vertical scrollbar in WinForms GridControl.
You can refer to WinForms GridControl feature tour page to know about its other groundbreaking feature representations and WinForms GridControl documentation, and how to quickly get started for configuration specifications. You can also explore our WinForms GridControl example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!