Change PopupMenu text?

Hi,
Is it possible to change the text of a PopupMenu’s selected row?

Foe example:

If the PopupMenu’s text is currently, “Option1” - is it possible to change it to “Option1a” - without having to delete all rows and then repopulate it?

I tried the code below - but I get an error saying “cannot assign a value to this property” :

Window1.PopupMenu1.text = Window1.PopupMenu1.text + "a"

Thanks.

Looking at the documentation for PopupMenu, the Text property is read only. You will have to remove all the rows, repopulate with the updated item, and reselect it with ListIndex.

It seems possible to use removerow and insertrow to change a particular option.

Thanks guys.

I do not want to delete all rows and then repopulate, and I don’t think removeRow and insertRow will cause the popupmenu entries to stay in exactly the same order (but with a replaced row)?

Hmmmm.

I suppose that would work too :slight_smile:

RemoveRow and InsertRow, still requires the popupmenu to be repopulated :frowning:
I need something like ReplaceRow (but it doesn’t exist) :frowning:

Yeah right. The Earth is flat :stuck_out_tongue:

It does. Just checked now :slight_smile:

In a module :

Sub ReplaceRow(Extends popmenu as PopupMenu, RowNumber as Integer, Item as String) if RowNumber > popmenu.ListCount or RowNumber < 0 then return popmenu.RemoveRow(RowNumber) popmenu.InsertRow(RowNumber,Item) End Sub

Example of use :

  if PopupMenu1.ListIndex >=0 then PopupMenu1.ReplaceRow(PopupMenu1.ListIndex,"Boo !")

Nice one Mr Budjardet - I will try that later when I’m back at my computer.
Thank you for your help - much appreciated.

if RowNumber > popmenu.ListCount or ...

This should be >=

Yes.