Clear Strings in a PopUpMenu

1 Ansicht (letzte 30 Tage)
Franco
Franco am 10 Jul. 2014
Bearbeitet: Ben11 am 10 Jul. 2014
So I have built a GUI with a popupmenu. Say that the strings in the popupmenu are {'1','2','3'}. In this same GUI, I have a button that is supposed to repopulate the strings in the popupmenu. Say, that I push the button and instead of populating the popupmenu with {'1','2','3'}, I push the button and I want to populate it with {'5','4'}. The result is now a popupmenu with strings {'5','4','3'}. What I want to know is either 1. How do I clear the strings in the popupmenu before populating it, or 2. How do I get rid of the entry (the last 3 in this case) that is unwanted. Thanks in advance for your help.

Akzeptierte Antwort

Ben11
Ben11 am 10 Jul. 2014
Bearbeitet: Ben11 am 10 Jul. 2014
You can control what appears in the popup menu by using a cell array containing the strings you want to display.
For instance you don't have to clear the existing popup menu's content but rather replace it with what you want:
MyStrings = {'5' '4'};
set(handlesToPopupMenu,'String',MyStrings);
and it should update correctly. If on the other hand you want to retrieve the content of the popup menu as a cell array, use this:
MyStrings = cellstr(get(handlesToPopupMenu,'String'));

Weitere Antworten (0)

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by