From Xojo Documentation
Jump to: navigation, search
For web applications, see WebPopupMenu.

Class (inherits from RectControl)

Displays a list of items when clicked. The user can select one item from the list. The ComboBox control is similar except that the user also has the option of typing an item instead of choosing one from the list of items.

Change DropObject MouseExit
Close GotFocus MouseMove
ConstructContextualMenu KeyDown MouseUp
ContextualMenuAction KeyUp MouseWheel
DragEnter LostFocus Open
DragExit MouseDown
DragOver MouseEnter

Active ReadOnlyProperty.png List ReadOnlyProperty.png Scope ReadOnlyProperty.png
AutoDeactivate ListCount ReadOnlyProperty.png TabIndex
Bold ListIndex TabStop
DataField ReadOnlyProperty.png LockBottom Text ReadOnlyProperty.png
DataSource ReadOnlyProperty.png LockLeft TextFont
Enabled LockRight TextSize
Handle ReadOnlyProperty.png LockTop Top
Height MouseCursor Transparent
HelpTag MouseX ReadOnlyProperty.png TrueWindow ReadOnlyProperty.png
Index ReadOnlyProperty.png MouseY ReadOnlyProperty.png Underline
InitialValue ReadOnlyProperty.png Name Visible
Italic PanelIndex Width
Left Parent Window ReadOnlyProperty.png

AcceptFileDrop AddSeparator Refresh
AcceptPictureDrop Close RefreshRect
AcceptRawDataDrop DeleteAllRows RemoveRow
AcceptTextDrop DrawInto RowTag
AddRow InsertRow SetFocus
AddRows Invalidate


NOTE: Changing the Height property has no effect for apps run on macOS. As a native control, macOS always draws the PopupMenu at its system-standard height.

Warning24.png The MouseDown and MouseUp event handlers are never called on Linux due to a limitation of the underlying GtkComboBox that is used. [1]

Warning24.png ContextualMenus do not work with PopupMenu on macOS due to a limitation of the underlying macOS control that is used.


This code in the Open event handler populates a popup menu and sets the initial value to the current month:

Dim months() As String = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
For Each m As String In months

Dim d As New Date
Me.ListIndex = d.Month - 1 // Select current month

Examine the value of ListIndex in the Change event handler to determine which item was selected.

This example adds an item to PopupMenu:


This example populates the RowTag identifier with a sequence number:

For i As Integer =0 To Me.ListCount - 1
Me.RowTag(i) = i

Since RowTag is a Variant, you must first convert it to an Integer if you want to compare it to another integer. Do this with a simple assignment statement such as:

Dim recID As Integer
recID = PopupMenu1.RowTag(1)

Then compare recID to another Integer.

This example opens a new window when an item is chosen.

Sub Change()
Dim w As ListEditorWindow

If PopupMenu1.Text = "Edit List..." Then
w = New ListEditorWindow
End If

Changing the selected item in a PopupMenu:

PopupMenu1.ListIndex = 3 // Selects the 4th item in the list (0-based)

Displaying the RowTag of the selected menu item:

TexField1.Text = PopupMenu1.RowTag(PopupMenu1.ListIndex)

See Also

BevelButton, ComboBox, TextField controls; RectControl class.

Personal tools

Starting Out
Dig Deeper
More Help