[RESOLVED] Prevent a menu from popping up
When I right-click on a listview, a menu pops up with a number of options such as "delete the selected item" etc. Now, I want to prevent the menu from popping up when the listview is empty. So far I've used:
VB Code:
If ListView1.ListItems.Count = 0 Then mnuHidden.Visible = False
but I think it's not the way to go, as the menu is (very briefly) shown before is becomes invisible.
Re: Prevent a menu from popping up
Quote:
Originally Posted by krtxmrtz
When I right-click on a listview, a menu pops up with a number of options such as "delete the selected item" etc. Now, I want to prevent the menu from popping up when the listview is empty. So far I've used:
VB Code:
If ListView1.ListItems.Count = 0 Then mnuHidden.Visible = False
but I think it's not the way to go, as the menu is (very briefly) shown before is becomes invisible.
Forget about it... :blush: I think I'm still asleep this morning...
VB Code:
Private Sub ListView1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
If ListView1.ListItems.Count > 0 Then
PopupMenu mnuHidden, , ListView1.Left + X, ListView1.Top + Y
End If
End If
End Sub