How to disable context menu for vertical scrollbar in WinForms GridControl?
WinForms Grid Control, you can disable the context menu for scroll bar by cancelling the showContextMenu Here, context menu is handled by comparing the width of the ClientRectangle and the width of the mouse pointer for vertical scroll bar.
C#
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; } }
VB
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 context menu for vertical scrollbar in WinForms GridControl.
You can refer to our WinForms Grid Control feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WinForms Grid Control 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!