I have two popup menus and would like to show only specific menu items in the second popup menu, depending on what is chosen in the 1st popup menu. How would I code this?
I tried this, but that doesn’t seem to way to do this:
if PopQSCategory.SelectedRowIndex = 0 then // If the Action Category is selected from the PopQSCategory popup menu...
//Show Story Type values 0-9
PopQSStoryType.InitialValue = "Capture and Escape" + "Chase" + "Coming of Age" + "Kidnap and Rescue" + "Local Adventure" + "Love Story" + "Puzzle" + "Revenge" + "Supernatural Transformation" + "Triumphant Victim"
end if
Also, how is this kind of instruction called? So I can search for this.
InitialValue is read-only. It can only be set in the inspector, not by code.
What you want to do is remove all rows, then replace them with new items.
For instance if PopupMenu1 had 2 choices of Letters or Numbers, in the SelectionChanged event of Popup #1 you would have something like:
If Me.SelectedRowIndex = 0 Then
PopupMenu2.RemoveAllRows
PopupMenu2.AddAllRows("A", "B", "C", "D", "E", "F", "G", "H", "I", "J")
ElseIf Me.SelectedRowIndex = 1 Then
PopupMenu2.RemoveAllRows
PopupMenu2.AddAllRows("1", "2", "3", "4", "5", "6", "7", "8", "9", "10")
End If
You’ll want to check out AddAllRows, AddRow, and AddRowAt, RowValueAt, among others in the DesktopPopuMenu documentation. DesktopPopupMenu — Xojo documentation
Thanks so much, Mark. This works great.