Get MenuItem from UIExtensionSites

Topics: CAB & Smart Client Software Factory
Mar 6, 2007 at 9:54 AM
Hi!

I am adding ToolStripMenuItems to WorkItem.UIExtensionSites at runtime.
Based on the active Workitem view I need to enable or disable some of thows menu items.
How can I get the reference to added ToolStripMenuItems through WorkItem ?

Thanks,
Edijs
Mar 6, 2007 at 5:20 PM
I am assuming that each of those ToolStripMenuItems you want to disable are binded to a Command, am I right? There is actually a way to disable a Command, and CAB has adapters that get notified when a command is disabled, and change the Enabled property on the invoker’s ToolStripItem to false.
So this is what you should do when a workitem becomes activated:
WorkItem.Commands“MyCommandName”.Status = CommandStatus.Disabled (or Enabled)
This will automatically disable (or enable) your MenuStripItem besides just disabling (or enabling) the command.

Let me know if this helps
Julian Dominguez
http://staff.southworks.net/blogs/jdominguez
Mar 9, 2007 at 8:37 AM
Julian,
that is exactly what I was looking for.

Thanks a lot!

Regards,
Edijs
Apr 13, 2007 at 10:30 AM
And what if I want to check or uncheck my menu items ?
Would it be nice to get the MenuItem from the UIExtensionSite at runtime to change such properties.

Regards
Daniel
Apr 13, 2007 at 3:01 PM
OK I've found the answer in an earlier thread.
http://www.codeplex.com/smartclient/Thread/View.aspx?ThreadId=5392