Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1595
  • Last Modified:

ListView Popup Menu - Show Menu on Item click dont show menu when no data right click on.

i have a listview and im trying to find out when I right click on on any item in the listview i want it to bring the popup menu up. And if I right click in the white area where their is no data i dont want the menu to appear. The data will change on a daily basis.

If Button = 2 Then
    If LVCity.SelectedItem.Selected = True Then
        PopupMenu frmMain_SysTray.mCountryMaint
    End If
End If

With LVCity
    .View = lvwReport
    .ColumnHeaders.Add , , "ID", 0
    .ColumnHeaders.Add , , "City/Town Name", 2000
End With
1 Solution
you should use the Hittest function before showing the popup menu.
With the hittest function, you can test wheter there is an item at the spot you clicked or not.

I cannot get to my source codes right know, but search in msdn help for hittest and maybe you can find it out.
may be just

If LVCity.SelectedItem.Selected = True and len(LVCity.SelectedItem.text) Then

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now