Change toolbar button icon at runtime

Hello !

I wonder if it’s possible to change the icon of a toolbar button with code… i tried some ideas but the do not work…

Mac? Win? Linux?
Using built in toolbar classes?
Isn’t WebToolbarButton.Icon settable?

Hello Christian !

Mac and Window and using the built in toolbar class.

Unfortunately the only options i see in the code are Caption, Enabled, HelpTag, Name and Tag

Any MBS magic for this ? :slight_smile:

Toolbar.Item returns a ToolItem. Usually these will be instances of ToolButton, so you can cast the item to that and then set its Icon property.

This works for me

[code]dim B as new ToolButton
dim stand as integer

stand = flights + ( hours * 1.4)

//Wenn Trainingsstand < 28 dann roter Bereich
//Wenn Trainingsstand >= 28 und < 56 dann gelber Bereich
//Wenn Trainingsstand >= 56 dann grüner Bereich

if toolbar11.item(4) isa ToolButton then
b=ToolButton(Toolbar11.item(4))
if stand < 28 then
b.icon=barred_48
elseif stand >= 28 and stand < 56 then
b.icon=baryel_48
elseif stand >=56 then
b.icon=bargre_48
end if
end if[/code]

barred_48, baryel_48 and bargre_48 are images I added to my project

The code is is a sub that is called whenever I need to check, if the icon needs to be changed.

Thanks a lot Joe and Stefan.

Still i have to catch the logic behind this, but in the meantime it works magically !