vb.net - How to display Drop Down item TEXT from Menu Strip -


what wish achieve extract select item text , display messagebox (for start, i'm going use sql query...)

i want extract particular selected item, instance : "spr (suivi piece rechange)" in following image :

enter image description here

i tried this, when click on "menu", returns name of menu strip "menustrip1" :

private sub menustrip1_click(byval sender system.object, byval e system.eventargs) handles menustrip1.click     messagebox.show(directcast(sender, menustrip).name) end sub 

edit:

i forgot mention items added dynamically database, there no predefined private sub....end sub procedure these items.

thanks in advance.

the menustrip object refers actual menu strip itself, not individual menu items, toolstripmenuitem objects. you're looking text property of objects. example:

directcast(yourdynamicmenuitemobjecthere, toolstripmenuitem).text 

if you're looking way capture events, you'll need create generic event handler:

private sub genericmenuitem_click(sender system.object, e system.eventargs)     messagebox.show(directcast(sender, toolstripmenuitem).text)     'whatever else need based on text of menu item end sub 

and hook handler menu items whenever they're created:

'code creates yourdynamicallygeneratedmenuitem addhandler yourdynamicallygeneratedmenuitem.click, addressof genericmenuitem_click 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -