Disable menu items.


Author
Message
Steve Warner
Steve Warner
Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)
Group: Forum Members
Posts: 15, Visits: 1
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?
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K
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;
      }
   }
}



Best Regards,
Nevron Support Team


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search