How To Update A MenuItem

Docking/MDI for Windows Forms Forum

Posted 14 years ago by JohnH
Avatar
Similiar to Visual Studio's IDE, I need to be able to change the structure of a menuItem(s) on my app's main menu and buttons on the related toolbars.

The structure of the menus (on the main menu) is to be set at runtime depending on the control (treeview, textbox, etc.), that has focus and contained in some toolwindow.

So, for example, some menuItems (Cut, Copy, etc.) on the Edit menu may be enabled when a textBox has focus, than when a treeview has focus in some other toolWindow.

I can resort to Win32 API calls, but that has its own set of issues.

Is there a mechanism in the UIStudio framework to ease this tedious menu maintainance task?

Comments (4)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi John,

With our bar controls, things like enabled states are all centralized in the command. So like if you wanted to disable all instances of an "Edit.Copy" button, you'd set the command's Enabled property to false like this:
barManager.Commands["Edit.Copy"].Enabled = false;
That single statement updates all links that reference that command so that they appear disabled. This is extremely powerful. In other toolbar systems, you would have to iterate through all the toolbars and menus yourself to look for each instance of a command link, but not with UIStudio. This is even more important when you consider that the end user can totally customize links with UIStudio and create "Edit.Copy" links wherever they want.

We have a couple other things that help with your scenario. Our CommandPopup event fires whenever a command link is about to show its child menu, allowing you to update enabled states or menu structures on the fly.

Also, we have a CommandUpdate event that fires at an interval which you can set (you have to set an interval to activate it) and constantly polls so that you can update enabled states there if you'd like.

So all those things help, and definitely having the core command / command link design of our bar controls makes mass updates easier than most other products.


Actipro Software Support

Posted 14 years ago by JohnH
Avatar
Okay, great, this bar Control/Manager sounds like what I'm after.

1. Is this barManager new to UIStudio v2?

2. This may save me a bunch of coding/testing time. Maybe you can point me to some code examples to reduce the trial-and-error, learning curve thing?

BTW: Great tech support! I appreciate the prompt reply.

Thanks,
John
Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Oops, when I replied, I thought you were already checking out our bar controls. :)

Yes, they are new in the 2.0 pre-release that is available from a special link on our Download page.

We're always happy to help you understand how it works via email or forums posts. And if you see any areas in the documentation that are unclear, let us know and we can try to improve them.

Our implementation of the bar controls use some advanced concepts but once you understand them, it's really nice, especially for large applications that have a lot of commands and need to allow for end user customization.


Actipro Software Support

Posted 14 years ago by JohnH
Avatar
Thanks for reply.

Yeah, I am checking out the 2.0 pre-release; I was thinking perhaps I missed this feature in the 1.x version.

Anyway, I'll be digging into the beta 2.0 samples and look forward to the prod release.

John
The latest build of this product (v2018.1 build 0341) was released 9 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.