How to retrieve a WebToolbarButton with a Tag?

I have a WebToolbar with a range of buttons and one menu (with the Tag “Services”) already on it. I want to retrieve the WebToolbarButton for the menu, so I can re-populate the values on it.

I know how to remove the existing menu items from the WebToolbarButton menu and I know how to add the new menu items on, but I don’t know how to retrieve the WebToolbarButton for the menu based on its Tag.

'In the Open Event
Var tempWebToolbarButton As New WebToolbarButton
tempWebToolbarButton.Style = WebToolbarButton.ButtonStyles.Menu
tempWebToolbarButton.Caption = "Services"
tempWebToolbarButton.Tag = "Services"
WinTimeBillIt.MainToolbar.AddItem(tempWebToolbarButton)

'later in another Method
Var tempWebToolbarButton As New WebToolbarButton
'this retrieves a ToolBarMenuItem, but not the WebToolbarButton
tempWebToolbarButton = WinTimeBillIt.MainToolbar.ItemWithTag("Services") '<< error here

How can I retrieve the WebToolbarButton itself?

Please try the “Pressed” event and then

if item.Caption = "Services" then
 ...
end if

Ah, sorry - I read too quickly on a small screen, you are asking for retrieving the button … do you have an error message?

I don’t want to wait until the WebToolbarButton is Pressed. I know the few times I need to refresh the menu items.

I can determine the WebToolbarItem using WebToolbar.ItemWithTag(“Services”), but I am not sure how to turn this into a WebToolbarButton so I can update its menu items.

Perhaps this is not yet implemented? I have a “similar” issue, that if I have something like this:

productsButton.Style = WebToolbarButton.ButtonStyles.Menu
productsButton.Caption = "Products"

and then items below, I can not retrieve if some has bushed the Products Button in the toolbar, it “only” opens the menu, so there is apparently no differentiation between the little arrow next to the Products-Button (to open the menu) and the whole button as such …

I may have fixed it with:

Var tempWebToolbarItem As WebToolbarItem = WinLogin.LoginToolbar.ItemWithTag("Services")
Var tempWebToolbarButton As WebToolbarButton

If tempWebToolbarItem IsA WebToolbarButton Then
  tempWebToolbarButton = WebToolbarButton(tempWebToolbarItem)
End If

I’ll test it.

1 Like

Yes, that works, thank you @Jeannot_Muller

1 Like

You are welcome, but I didn’t much, you found the solution on your own :-).

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.