Adding a WebToolbarButton in code

I would like to add buttons to a toolbar. This code in the toolbar open compiles and runs, but does not add another button.

button = new WebToolbarButton if button <> nil Then[code] button.Name = "bNew" button.Caption = "New" me.Width = 500 end if
Is it possible to do this? I suppose I can also change or erase button captions and icons so they aren’t visible.

Yes, it is impossible :frowning:

A WebToolbar is a design time control. I have an instance where I need to have different buttons depending on an Admin state or not. The only work around I found was to have two toolbars. I toggle the visibility/enabled status of one or the other depending on the role of the user. Not a nice way to do it at all, but it is working.

Hopefully in the future the WebToolbar will be more capable, at least being able to make buttons invisible.

Maybe there is a JavaScript way of doing that now, I don’t know.

I have found that I can shorten a toolbar either by changing its width or setting the captions and icons to null values.

Hi Dean Davidge,

you can append buttons during runtime - just add

toolbar1.AppendItem (button) - after your code

Jeremy Cowgar,

you can hide a toolbar button like this.

Dim Button as WebToolbarButton
button = WebToolbarButton(toolbar1.ItemAtIndex(0))
button.Enabled = False
button.Caption = “”

hope this helps

You can always imbed a WebToolBarButton in a WebContainer and then add them runtime.

Yes, adding toolbar buttons is something that was added to the framework (unsure which version). It didn’t use to be possible.