2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
Show context menu stripBy default, the ContextMenuStrip opens only on right click over the associated control. When the cell is in edit mode, it no longer receives mouse-related events. The control (TextBox or ComboBox) present in the cell alone receives the mouse events. So, to have a ContextMenuStrip in the edit mode, you need to set the ContextMenuStrip for those controls present in the cell. This can be achieved by handling the events CurrentCellControlGotFocus, CurrentCellControlLostFocus and MouseDown. C# void gridControl1_CurrentCellControlLostFocus(object sender, ControlEventArgs e) { e.Control.MouseDown -= new MouseEventHandler(Control_MouseDown); } void Control_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) this.contextMenuStrip1.Show(Control.MousePosition.X, Control.MousePosition.Y); } void gridControl1_CurrentCellControlGotFocus(object sender, ControlEventArgs e) { e.Control.MouseDown += new MouseEventHandler(Control_MouseDown); }
VB Private Sub gridControl1_CurrentCellControlLostFocus(ByVal sender As Object, ByVal e As ControlEventArgs) RemoveHandler e.Control.MouseDown, AddressOf Control_MouseDown End Sub Private Sub Control_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) If e.Button = MouseButtons.Right Then Me.contextMenuStrip1.Show(Control.MousePosition.X, Control.MousePosition.Y) End If End Sub Private Sub gridControl1_CurrentCellControlGotFocus(ByVal sender As Object, ByVal e As ControlEventArgs) AddHandler e.Control.MouseDown, AddressOf Control_MouseDown End Sub Samples: C#: ContextMenu-C#. VB: ContextMenu-VB. |
2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
This page will automatically be redirected to the sign-in page in 10 seconds.