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

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -