0

I would like to have a menu with two options when user right clicks listbox. With that menu user would do some actions on selected data, e.g. add new line, change some columns data or delete row. I think I can manage that code but I can not grasp how to create a right click custom menu.

I can not find a way to create such option. Does anyone has an idea?

Simple right click example

Tomislav Horvat
  • 163
  • 1
  • 8
  • There is no right click event for listboxes. You could likely create a custom listener, but that's beyond me. You may be better off adding one or more buttons to the UF or sheet holding these options – Tim Stack Apr 24 '19 at 09:51
  • Thank you Tim, I was hoping there was some workaround. :( – Tomislav Horvat Apr 24 '19 at 09:53

2 Answers2

0

Here's some code for the right click event:

Select ListBox item on rightclick in Word VBA

Replace this code with your context menu code:

Me.Caption = derivedIndex & " = " & ListBox1.List(derivedIndex)

Here's a example for the popup menu (you need skills to understand Win32 API calls...) https://www.vbarchiv.net/api/api_createpopupmenu.html

Shmukko
  • 572
  • 3
  • 11
  • Thank you for input, unfortunately I am not that good with German language to understand your Win32 API call..I think I will make a simple double click that will open hidden edit form and buttons for adding a new line and removing selected line. – Tomislav Horvat Apr 25 '19 at 08:26
0

The right click menu on the listbox that created by using only a class(without using Api or Declare function) contains the following buttons ;

  • Increase Font Size
  • Decrease Font Size
  • Sort A-Z
  • Remove List
  • Remove All

enter image description here

For VBA codes and sample file review this link

kadrleyn
  • 364
  • 1
  • 5