I want to know how can I disable/enable a MenuStrip Item and How to disable/enable a menustrip item's DropDownCollection particular item.
A Picture is given of my menustrip and "Account Department" is the DropDownCollection Item Which I want to Disable/Enable according to conditions.
I have a line of code which disable Main MenuStrip Item in this case "Departments" is the Item.
That line of code is:
menuStrip1.Items[1] = false;
如果您将该项目命名为“ Menu1”,则可以轻松启用或禁用它:
Menu1.Enabled = false;
As others said you can set the menu item's Enabled property, but It's better to give a name to the menu item that you are trying to change. then you can easily set it's enabled property as you want, for example name it menuitemAccountDepartment and then:
menuitemAccountDepartment.Enabled = false;
It's more readable and more manageable.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.