DesktopPopUpMenu AddRow

XOJO 24r3 / Windows 11
I’m converting my app to API2 Desktop.
I converted a PopupMenu to a DesktopPopUpMenu.
In my code cbo1 is a DesktopPopUpMenu and sourceStyle is a Collection.

For i = 1 To sourceStyle.Count
  cbo1.AddRow sourceStyle.Item(i)
  cbo1.RowTagAt(i-1) = sourceStyle.Key(i)
Next

What do I wrong ? How to solve this ?
The error I get is - There is more than one method with this name but this does not match any of the available signatures.

Regards
Etienne

Oeps.
Apparently adding StringValue solves my problem.

For i = 1 To sourceStyle.Count
  cbo1.AddRow sourceStyle.Item(i).StringValue
  cbo1.RowTagAt(i-1) = sourceStyle.Key(i)
Next

Regards

Which line does this error belong to?

The argument to AddRow has to be a string or DesktopMenuItem.

Hi Tim,
The line was

cbo1.AddRow sourceStyle.item(i)

But I solved it with -

cbo1.AddRow sourceStyle.item(i).StringValue

You are right, it needs to be a String.
And I suppose my collection item was a Variant.
Without the .StringValue it worked in XOJO 2021r1.

Regards
Etienne

And in the next line, you apply a RowTag to the previous Row. Error or In Purpose ?

Presumably because .RowTagAt requires a zero-based value whereas it looks like the Collection is 1-based.

May I ask you why you’re supposing?
I fear you could get in troubles later if you’re unsure what your array is.

I checked it and the collection item is indeed a Variant.

Regards
Etienne

1 Like

By the way the docuentation for Collection recommends using a Dictionary rather than a Collection. Same features, faster.