Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How can I display a shortcut menu when user right clicks a cell?

0
Posted

How can I display a shortcut menu when user right clicks a cell?

0

If you want to provide different shortcut menus for control depending on clicked cell, the MouseUp or MouseDown events should be used. Else, if you want to provide a general shortcut menu, the RClick event can be used too. The following sample handles the MouseUp event and displays a shortcut menu when user right clicks a cell: Private Sub Tree1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) ‘ Checks whether the user right clicks the mouse If (Button = 2) Then ‘ Gets the cell from point Dim h As HITEM, c As Long, i As Long, hit as Long h = Tree1.ItemFromPoint(X / Screen.TwipsPerPixelX, Y / Screen.TwipsPerPixelY, c, hit) ‘ Displays a popup menu if the right clicks a cell If (h <> 0) Then i = PopupMenu1.ShowAtCursor() If (i > 0) Then ‘ Displays the identifier of the context menu item selected Debug.Print “You have selected the item ” & i End If End If End If End Sub The sample uses the exPopupMenu that can be downloaded here.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123