How can a GUI pop up menu be made to show the previous selected option?

1 次查看(过去 30 天)
I want to rephrase my earlier question as follows:
How can a GUI pop up menu be made to show the last selected option?

回答(2 个)

Image Analyst
Image Analyst 2013-4-12
This would probably work, though I haven't tested it.
allItems = get(handles.popup, 'string');
numberOfItems = length(allItems);
set(handles.popup, 'value', numberOfItems);
  10 个评论
Image Analyst
Image Analyst 2013-4-12
If that will acceptable, then please mark the answer as "Accepted" to close this out. Thanks.

请先登录,再进行评论。


Yao Li
Yao Li 2013-4-12
allItems = get(handles.popupmenu1, 'string')
set(handles.popupmenu1,'String',allItems);
  13 个评论
Shyam
Shyam 2013-4-12
but if u close matlab then the value u stored using setappdata is lost.... how to retain the value?
Image Analyst
Image Analyst 2013-4-12
Obviously. If you want to save the value to a disk file, you can do that with save() or fprintf(), or even xlswrite() or dlmwrite.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by