G
Guest
Listviews in access have been the highlight of my year; they beat the pants off the normal list box! I've got a quite a complex listview at the moment, of which there is a lot of conditional formatting, sorting, filtering etc going on.
One thing I would like to add is popup sub menus. To do this, I have handled the Right click event with the following:
Private Sub axListTests_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Long, ByVal y As Long)
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Sub menu controls for Right click
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim lvxObj As ListView
Set lvxObj = axListTests.Object
Dim lstItem As ListItem
Set lstItem = lvxObj.HitTest(x, y)
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Test for an Item, then show submenu
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If lstItem Is Nothing Then
'Sub menu for white space
MsgBox "Sub menu for Add New Item"
Else
Select Case Button
Case 1
'left button clicked no action required (handled by DoubleClick)
Case 2
'right button clicked
'Sub menu for Selected item
MsgBox "Submenu Goes here for item " & lstItem
lvxObj.HoverSelection
lvxObj.View
End Select
End If
End Sub
As you can see, I can produce a message box depending on what item was right-clicked, or if no item was right-clicked.
The next stage is to produce a popup sub menu... the type you see in Windows Explorer that when you right-click a file you get a small menu with Open, Rename, Cut, Copy blah blah blah.. Well I wanna do the same, but with my own custom commands:
- Open Item
- Delete Item
So the two questions are:
1) How can I create submenus
2) how can I handle click events on submenu items?
TIA...
One thing I would like to add is popup sub menus. To do this, I have handled the Right click event with the following:
Private Sub axListTests_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Long, ByVal y As Long)
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Sub menu controls for Right click
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim lvxObj As ListView
Set lvxObj = axListTests.Object
Dim lstItem As ListItem
Set lstItem = lvxObj.HitTest(x, y)
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Test for an Item, then show submenu
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If lstItem Is Nothing Then
'Sub menu for white space
MsgBox "Sub menu for Add New Item"
Else
Select Case Button
Case 1
'left button clicked no action required (handled by DoubleClick)
Case 2
'right button clicked
'Sub menu for Selected item
MsgBox "Submenu Goes here for item " & lstItem
lvxObj.HoverSelection
lvxObj.View
End Select
End If
End Sub
As you can see, I can produce a message box depending on what item was right-clicked, or if no item was right-clicked.
The next stage is to produce a popup sub menu... the type you see in Windows Explorer that when you right-click a file you get a small menu with Open, Rename, Cut, Copy blah blah blah.. Well I wanna do the same, but with my own custom commands:
- Open Item
- Delete Item
So the two questions are:
1) How can I create submenus
2) how can I handle click events on submenu items?
TIA...