DesktopToolbar example, no member named "Add"

Good morning

Copied the DesktopToolbar example code from here:

https://documentation.xojo.com/api/user_interface/desktop/desktoptoolbar.html

When running it throws an error that “Add” is not a member of the toolbar…

Var dropDownButton As New DesktopToolbarButton
dropDownButton.ButtonStyle = DesktopToolbarButton.ButtonStyles.DropDownMenu
dropDownButton.Caption = "Cities"
dropDownButton.Name = "CitiesMenu"

// Create a menu
Var myMenu As New DesktopMenuItem
myMenu.AddMenu(New DesktopMenuItem("Grand Blanc"))
myMenu.AddMenu(New DesktopMenuItem("Bad Axe"))
myMenu.AddMenu(New DesktopMenuItem("Flint"))

// Assign the new menu to the toolitem..
dropDownButton.Menu = myMenu

// Add to the toolbar
Me.Add(dropDownButton)

The last line should be:

Me.AddButton(dropDownButton)

1 Like

The LR states:

The following code is in the Opening event of the DesktopToolbar instance in the window.

So, Me refers to the DesktopToolBar. If you place the code elsewhere, it refers to something who does not know what Me is.

Is Me talking good english ? :grinning:

Ehm…I wasn’t talking about “Me”…

“Add” isn’t known…I had to use “AddButton”…

Sorry… I opened the LR for DesktopToolbar, then someone comes… wrong answer.

That said, I do not saw any .Add in the LR page:
DesktopToolbar

There are two .Add: .AddButton (Append) and .AddButtonAt (Insert).

Maybe that is why the autocomplete feature stops at .Add ?

Ah my fault…posted the wrong link (o;

Here it uses the wrong method “Add”:

https://documentation.xojo.com/api/user_interface/desktop/desktoptoolbarbutton.html

Ehm…where do you got this screenshot from?

The above example is from DesktopToolbarButton:

And exact this example throws this error then when not changing last line from Me.Add to Me.AddButton:

Right link:
https://documentation.xojo.com/api/code_execution/to.htmlolbarButton

Your page must have been a copy/paste of my page and they forget to correct the example. PROBABLY.

That is why I looked at the previous page.

I was eating, so typing (all the text) with only my left hand is a bit difficult for me. :grinning:

Fixed. Thank you for pointing this out.