context menu in vb.net -


i have dynamically populated list in windows forms application. want add context menu such when select item, context menu appear when right click on selected item, , not appear on right-click on other blank areas of form. using code.

lv.columns.add("button text", 300, horizontalalignment.left) lv.columns.add("pid", 50, horizontalalignment.left) lv.columns.add("process path", 300, horizontalalignment.left) lv.columns.add("hide icon permanently", 150, horizontalalignment.left)  dim things list(of traybutton) = trayhelper.tray.gettraybuttons() each b traybutton in things     if b.icon isnot nothing         il.images.add(b.trayindex.tostring, b.icon)     else         ' when can't find icon, listview display form's one.         ' try grab icon process path suppose.          il.images.add(b.trayindex.tostring, me.icon)     end if     dim lvi new listviewitem(b.text)     lvi.subitems.add(b.processidentifier.tostring)     lvi.subitems.add(b.processpath)     lvi.imagekey = b.trayindex.tostring     lv.items.add(lvi)  next  dim mnucontextmenu new contextmenu() me.contextmenu = mnucontextmenu dim mnuitemhide new menuitem() mnuitemhide.text = "&hide"  mnucontextmenu.menuitems.add(mnuitemhide) 

assign contextmenu listview then...

change:

me.contextmenu = mnucontextmenu 

to:

lv.contextmenu = mnucontextmenu 

if it's not obvious, me changed lv.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -