How to get the data from a popup menu and display the selected data in list box?

2 ビュー (過去 30 日間)
I'm having the problem that, I got one popup menu with three data and a list box. A push button which transfers the selected data from the popup menu to the list box. This is the concept. But I have the problem that, when I select one dat6a from the popup menu all the data appears instead the selected.
Is there any possibility that, the string what I selected from the popup menu can be displayed as a label for a figure?

採用された回答

Matt Fig
Matt Fig 2012 年 8 月 17 日
編集済み: Matt Fig 2012 年 8 月 17 日
Here is a simple example. More basic GUI examples can be found here.
function [] = GUI_pop_to_list()
S.fh = figure('units','pixels',...
'position',[450 450 400 150],...
'menubar','none',...
'resize','off',...
'numbertitle','off',...
'name','GUI_pop_to_list');
S.pp = uicontrol('style','pop',...
'units','pix',...
'position',[10 60 190 40],...
'string',{'Data 1';'Data 2';'Data3'},...
'fontweight','bold',...
'horizontalalign','center',...
'fontsize',11);
S.ls = uicontrol('style','list',...
'units','pix',...
'position',[210 70 190 60],...
'backgroundcolor','w',...
'HorizontalAlign','left');
S.pb = uicontrol('style','push',...
'units','pix',...
'position',[10 10 380 40],...
'HorizontalAlign','left',...
'string','Transfer',...
'fontsize',14,'fontweight','bold',...
'callback',{@pb_call,S});
uicontrol(S.pp) % Give the editbox control.
function [] = pb_call(varargin)
% Callback for edit.
S = varargin{3};
E = get(S.pp,{'string','value'});
STR = get(S.ls,'string');
set(S.ls,'string',[STR;E{1}(E{2})])

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by