By Steve Warner - Thursday, December 23, 2010
I need to be able to "gray out" or disable menu items, i.e. File->New. I need to be able to do this without rebuilding the entire CommandBars. I do not want to do it at time of building the Menu, like in the CustomMenuBuilder class. Is there a simple way of a disabling a menu item on the fly so that users will know not to press it?
|
By Nevron Support - Thursday, December 30, 2010
Hi Trudy,
The diagram command bars manager will automatically update the Enabled state of the UI command that is used as a visual front end of a certain NDiagramCommand, such as the NOpenDrawingCommand. That is why you cannot simply disable the UI command itself, because the diagram command bars manager will reset it to result of the underlying NDiagramCommand after a certain period of time. You can however override the NOpenDrawingCommand implementation like this:
...
NDiagramCommand cmd = manager.Commander.Commands.GetCommandFromId((int)DiagramCommand.OpenDrawing); int index = manager.Commander.Commands.IndexOf(cmd); manager.Commander.Commands.RemoveAt(index); manager.Commander.Commands.Insert(index, new NMyOpenDrawingCommand());
...
public class NMyOpenDrawingCommand : NOpenDrawingCommand { public override bool Enabled { get { return false; } } }
|
|