Adding menu items during runtime in C# -


i'm still working on getting menu display of input devices on computer- pardon third question in simple.

here's code:

list<menuitem> inputdevice = new list<menuitem>(); menuitem mymenuiteminputdevices = new menuitem("&input devices"); sgfilemenu.menuitems.add(mymenuiteminputdevice); (int = 0; < devicecount; i++) {     inputdevicemenu.add(new menuitem(inputname[i]));     mymenuiteminputdevices.menuitems.add(inputdevicemenu[i]);     mymenuiteminputdevices.click += new system.eventhandler(this.mymenuiteminputdeviceclick); } 

this seems work fine, menu items added, good, clicks on dropdown list not working. i've done other work menus, , clicks in other code working correctly. tried putting

mymenuiteminputdevices.click += new system.eventhandler(this.mymenuiteminputdeviceclick); 

outside of {}, in case right way it, didn't help.

what missing?

you want this

list<menuitem> inputdevice = new list<menuitem>(); menuitem mymenuiteminputdevices = new menuitem("&input devices"); sgfilemenu.menuitems.add(mymenuiteminputdevice); (int = 0; < devicecount; i++) {     inputdevicemenu.add(new menuitem(inputname[i]));     inputdevicemenu[i].click += new system.eventhandler(this.mymenuiteminputdeviceclick);     mymenuiteminputdevices.menuitems.add(inputdevicemenu[i]);     mymenuiteminputdevices.click += new system.eventhandler(this.mymenuiteminputdeviceclick); } 

edit: pretty obvious menu items trying add not have click event method hooked up.

    inputdevicemenu.add(new menuitem(inputname[i])); 

you adding them.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -