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

2 views (last 30 days)
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?

Accepted Answer

Matt Fig
Matt Fig on 17 Aug 2012
Edited: Matt Fig on 17 Aug 2012
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})])

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!