Adding items to a toolbar at runtime

Bars for Windows Forms Forum

Posted 18 years ago by Kasper
Avatar
Hi,

I seem to have a small problem. I'm using the latest build of UIStudio, and I wish to create and add items to a toolbar at runtime. I'm thinking that it's pretty simple, yet it doesn't work properly. After I've added som items, the toolbar gets all blank, and you can't see any items. Now, if the toolbar is docked, and you make it float, the items are shown again, and the same goes if the toolbar is floating and you dock it. I guess it needs a repaint or a resize or something, but I can't seem to find the proper method to call. Am I missing something here?

I simply get a reference to the toolbar with BarManager.DockableToolBars[], and then add items to it by using the toolbar.CommandLinks.Add() method.

Comments (5)

Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Yes for optimization reasons we don't perform a layout after each time a link is added. You can kick off a layout like this:
barManager.DockableToolBars["Standard"].Invalidate(InvalidationLevels.TopLevelParent, InvalidationTypes.All);


Actipro Software Support

Posted 18 years ago by Kasper
Avatar
Ah yes, I knew it was probably something like that. Thank you :)
Posted 18 years ago by Kasper
Avatar
For some reason, this is once again a problem for me. Was something changed in a release? The line of code you gave me worked fine before, but not anymore. When my toolbar is "rebuild", a bunch of items are gone. Now, all I need to do to get them to show up again is to minimize and restore the application, or simply make the toolbar floating instead of docked and so on. What can I do to make this work again?

Kind regards,

Kasper
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
The Invalidate code is what we call internally on resize so that should handle anything. If you are having an issue could you send over a small project that shows it? Thanks!


Actipro Software Support

Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
My apologies... the above code is wrong... it should be this instead:
barManager.DockableToolBars["Standard"].Invalidate(InvalidationLevels.All, InvalidationTypes.All);
The level of TopLevelParent will only invalidate the top-level-parent, meaning the DockArea but leaves the toolbars as valid. You want to invalidate all those things, so it should have been an All parameter instead.


Actipro Software Support

The latest build of this product (v24.1.0) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.