UserGuide

Web Popup Menu

From Xojo Documentation

Popup Menu controls are useful when you have a single list of data to present in a limited amount of space. It presents a list of items from which the user can choose one item.

You can add values to the Popup Menu by using the Set Default Value button on the toolbar, clicking the Pencil icon when hovering over the control or pressing Return while the control is selected.

Below are a list of commonly used events, properties and methods. Refer to WebPopupMenu in the Language Reference for the complete list.

Events

SelectionChanged

Called when the selected item in the popup menu has changed.

Properties

List

This property takes one parameter, an index of the row. It returns the text of the item in the popup menu specified by the index parameter. If the index does not exist, then an OutOfBoundsException is raised.

ListCount As Integer

An Integer containing the number of rows in the popup menu.

ListIndex As Integer

An Integer used to get or set the currently selected row in the popup menu.

Text As String

Contains the text of the currently selected row.

Methods

AddRow

Takes as a parameter a string or an array of strings to add a row or rows to the popup menu.

DeleteAllRows

Removes all rows from the popup menu.

IndexOfRow

Returns the row number in the list of the supplied value.

InsertRow

Takes as a parameter the row and name of item to insert into the popup menu.

RemoveRow

Takes as a parameter the number of the row to remove.

RowTag

Takes as a parameter the number of the row to which to assign the tag. The tag can be any value or class (variant).

Usage

Web Popup Menu

This code in the Shown event handler populates a Popup Menu:

Me.AddRow("North")
Me.AddRow("East")
Me.AddRow("South")
Me.AddRow("West")
Web Popup Menu with values in drop-down

This code in the SelectionChanged event handler displays the selected direction:

If Me.ListIndex >= 0 Then
MsgBox(Me.List(Me.ListIndex))
End If

This could also be written more simply as:

MsgBox(Me.Text)

See Also

WebPopupMenu class; UserGuide:Web UI topic