Say I’ve got a WebPopupMenu set up like this:
PopupMenu1.AddRow "1. Red"
PopupMenu1.AddRow "2. Green"
PopupMenu1.AddRow "3. Blue"
Now I want to change “2. Green” to “2. Yellow”.
It seems the following is invalid:
PopupMenu1.RowTextAt(1) = "2. Yellow"
I feel like I’m missing something basic as I don’t see a way to update a PopupMenu row as you can on Desktop. What’s the correct way to make this change?
Okay, turns out I’m not crazy after all; I don’t know why WebPopupMenu.RowTextAt is read-only. But here’s an extension method to allow it to work for setting a new text value.
Public Sub RowTextAt(extends c As WebPopupMenu, index As Integer, assigns newText As String)
If index >= 0 And index < c.RowCount Then
Var wasSelected As Boolean = (c.SelectedRowIndex = index)
c.RemoveRowAt(index)
c.AddRowAt(index, newText)
If wasSelected Then c.SelectedRowIndex = index
End If
End Sub