Hello all,
So I am using xojo 16 r3, and am trying to create a new popup menu inside a function. As it is shown bellow:
Dim tempPM As New PopupMenu
For i As Integer = 0 To 10
tempPM.AddRow(i.ToText)
tempPM.RowTag(tempPM.ListCount-1) = i
Next
While the object gets created by the end of the iteration my popup is still empty, both rows and rowtags.
Do I need to have a popup menu window item in the window? Is it not possible to use the popup menu item simply in the code?
Thanks in advance!!
No. You cant create a control from nothing.
Drag a pop up control onto your window. Set it outside the visible area if you like. Lets say you name it mypop
Make it a control array. Now your code reads
Dim tempMP As New mypop
OP you need to display the menu before you can get a result:
http://documentation.xojo.com/index.php/MenuItem.Popup
Here’s a working example of how to use this in a PushButton.Action event:
Sub Action() Handles Action
dim pmTemp as new MenuItem
for i as Integer = 1 to 10
pmTemp.Append(new MenuItem(str(i)))
next
dim pmSelection as MenuItem = pmTemp.PopUp
if pmSelection <> nil then
MsgBox("Selected " + pmSelection.Text)
end
End Sub
2 Likes
Thank you all for the replies, I ended up not using the popup menu. I used a Variant array to do the job I needed.
I works, so I am relieved! Thanx again!