SolarCoasters
01-24-2004, 11:40 PM
I made a context menu that I only want to pop up when a user right clicks on the grid. My book says that a context menu will pop up on any right click anywhere on the form. How do I make the menu pop up only when the user right clicks when over the msflexgrid control?
Thank you
Machaira
01-26-2004, 08:08 AM
Your book is incorrect. Only certain controls automatically have context menus associated with them. Since the MSFlexGrid is not a .NET control I believe you would have to display the menu manually:
Private Sub AxMSFlexGrid1_MouseDownEvent(ByVal sender As Object, ByVal e As AxMSFlexGridLib.DMSFlexGridEvents_MouseDownEvent) Handles AxMSFlexGrid1.MouseDownEvent
If e.button = 2 Then
ContextMenu1.Show(Me, New Point(AxMSFlexGrid1.Left + e.x, AxMSFlexGrid1.Top + e.y))
End If
End Sub
Private Sub MenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MenuItem1.Click, MenuItem2.Click, MenuItem3.Click
MsgBox(sender.text)
End Sub
Note that using the FlexGrid control in the Show method of the ContextMenu doesn't seem to work for calling the Click event of the menuitems, at least for me it didn't.