1. Matt Kleweno
  2. PowerBuilder
  3. Friday, 10 November 2023 19:25 PM UTC

I am trying to add a right mouse button menu to a ListView to perform an item delete function and perhaps other item related functions. 

The ListView is using the m_view menu object, but I can only get the RMB menu to appear when right clicking on the area to the right of the items on the list view.  When clicking on this area within the ListView, the item selection is removed, and SeletectItem() returns -1.  When I right click on the items in the ListView, no menu appears.  As such, m_view appears to apply only the the ListView as a whole.

Is there an RMB menu that relates to the items within the ListView, and if so, how can I activate it?


John Fauss Accepted Answer Pending Moderation
  1. Friday, 10 November 2023 21:25 PM UTC
  2. PowerBuilder
  3. # 1

Hi, Matt - 

I'm not sure what PB version you are using...

Looking at the PB Help for 2019 R3, under the RighClicked event of the ListView and Tab controls is a usage note:

"When the user clicks in the display area of the Tab control, the tab page user object gets an RButtonDown event rather than a RightClicked event for the Tab Control."

There is no mention of what happens in the ListView control's display area.

You might try adding a user event mapped to pbm_rbuttonup or pbm_rbuttondown to test if that fires when you right click in the display area of the ListView control. If it does, you should be able to display your own popup menu via the PopMenu PowerScript function.

Best regards, John

  1. John Fauss
  2. Monday, 13 November 2023 16:36 PM UTC
Is your application built upon the PowerBuilder Foundation Class (PFC) framework? If so, are you using the (older) ListView object u_lv or the (newer) ListView object u_lvs? The menu name "m_view" provided a hint that you may be using the PFC. If you are using the PFC, the ancestor ListView object contains code in the contextmenu event that configures and displays the popup menu. You can override this event script it make it do whatever you need it to do.
  1. Helpful 2
  1. Matt Kleweno
  2. Monday, 13 November 2023 22:20 PM UTC
Hi John,

Using the newer u_lvs listview solved the problem of displaying the menu when right clicking on the listview items. I also had to override the ancestor for the deleteitem event to get the SelectedItem value I needed for other work. If that event is extended the SelectedItem value is -1 once returning from the ancestor. Many thanks for solving my problem!
  1. Helpful
  1. John Fauss
  2. Monday, 13 November 2023 23:14 PM UTC
You're welcome, Matt. I'm glad you got the issue solved and I appreciate you sharing the solution!
  1. Helpful
There are no comments made yet.
  • Page :
  • 1

There are no replies made for this question yet.
However, you are not allowed to reply to this question.