c# - How to disable menu strip submenus -


i need disable menu item's sub child dynamically. here in menu bar if clcik run @ startup, disable startup option should disabled how achieve this. have attached snapshot reference

// run @ startup  private void runatstartuptoolstripmenuitem_click(object sender, eventargs e)  {    rkapp.setvalue("timecalculation", "\"" + application.executablepath.tostring() + "\"");    environment.getfolderpath(environment.specialfolder.startup);    menustrip1.items["disablestartuptoolstripmenuitem"].enabled = false;   }   //disable startup  private void disablestartuptoolstripmenuitem_click(object sender, eventargs e)  {    rkapp.deletevalue("timecalculation", false);    menustrip1.items["runatstartuptoolstripmenuitem"].enabled = false;  } 

snapshot:

enter image description here

use flag:

private bool flag = true;  private void runatstartuptoolstripmenuitem_click(object sender, eventargs e) {     //...     flag = true; }  private void disablestartuptoolstripmenuitem_click(object sender, eventargs e) {     //...     flag = false; } 

then use dropdownopening event enable/disable items.

private void btoolstripmenuitem_dropdownopening(object sender, eventargs e) {     runatstartuptoolstripmenuitem.enabled = !flag;     disablestartuptoolstripmenuitem.enabled = flag; } 

if want hide item use available:

    runatstartuptoolstripmenuitem.available= !flag;     disablestartuptoolstripmenuitem.available= flag; 

Comments

Popular posts from this blog

c# - SelectList with Dictionary, add values to the Dictionary after it's assigned to SelectList -

how can i manage url using .htaccess in php? -

ios - I get the error Property '...' not found on object of type '...' -