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

RowCount As Integer

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

SelectedRowIndex As Integer

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

SelectedRowValue 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.

RemoveAllRows

Removes all rows from the popup menu.

RowValueAt

Returns the value of the row at the index provided.

AddRowAt

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

RemoveRowAt

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

RowTagAt

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

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

Me.AddRow("North")
Me.AddRow("East")
Me.AddRow("South")
Me.AddRow("West")

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

If Me.SelectedRowIndex >= 0 Then
MessageBox(Me.SelectedRowValue)
End If

This could also be written more simply as:

MessageBox(Me.SelectedRowValue)

See Also

WebPopupMenu class; UserGuide:Web UI topic