I am adding MenuItems to my ContextMenu like this:
mnuContextMenu.MenuItems.Add("Delete", DeleteFile);
Now i want to disable this MenuItem, like this:
x.Enabled = false;
What MenuItem reference do I have to use for x?
I am adding MenuItems to my ContextMenu like this:
mnuContextMenu.MenuItems.Add("Delete", DeleteFile);
Now i want to disable this MenuItem, like this:
x.Enabled = false;
What MenuItem reference do I have to use for x?
You don't have anything to directly reference it. You could get it using the indexer of the MenuItems property:
or you could have a reference when creating it:
and then you have the reference to use later:
You may need to store it as a private data member of your class, rather than a local variable if you're planning to use it outside of your current function.