c# - onclick delegate is triggered only once -
i writing outlook add-in adds menu outlook. although set delegate action menu seems being removed after 1 call delegate - 1 click on menu item. next time user clicks not getting delegate. code example:
menucommand = (office.commandbarbutton)cmdbarcontrol.controls.add( office.msocontroltype.msocontrolbutton, missing, missing, missing, true); menucommand.caption = "&generate weekly..."; menucommand.tag = "generate"; menucommand.faceid = 65; menucommand.click += new microsoft.office.core._commandbarbuttonevents_clickeventhandler( menucommand_generate_click); menucommand = (office.commandbarbutton)cmdbarcontrol.controls.add( office.msocontroltype.msocontrolbutton, missing, missing, missing, true); menucommand.caption = "&about"; menucommand.tag = "about"; menucommand.faceid = 65; menucommand.click += new microsoft.office.core._commandbarbuttonevents_clickeventhandler( menucommand_about_click); menucommand.begingroup = true;
what should in order menu trigger action every time?
is menuitem local variable? , becouse garbage collector might clean in once falls out of scope.
try keeping variable in global object.
Comments
Post a Comment