Clear Strings in a PopUpMenu
1 回表示 (過去 30 日間)
古いコメントを表示
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.
0 件のコメント
採用された回答
Ben11
2014 年 7 月 10 日
編集済み: Ben11
2014 年 7 月 10 日
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'));
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Migrate GUIDE Apps についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!