You are on page 1of 3

LIST BOX

List box allows the user to select one item from a list contained within a static, multiple line
text box. The user clicks inside the box on an item to select it.
In the following GUI :the listbox string property considered as array , so
string(1)= 'maha' , value = 1
string(2)= 'ali' , value = 2
string(3)= 'ahmed' , value = 3

function listbox1_Callback(hObject, eventdata, handles)


h1=findobj('Tag','listbox1');
f=get(h1,'string');
v=get(h1,'value');
switch get(h1,'Value') If get(h1,'Value') == 1
case 1 msgbox( [ 'hello ' f(1) ] );
msgbox([ 'hello ' f(1)]); end
case 2 If get(h1,'Value') == 2
msgbox([ 'hello ' f(2)]); msgbox( [ 'hello ' f(2) ] );
case 3 end
msgbox([ 'hello ' f(3)]); If get(h1,'Value') == 3
end msgbox ( [ 'hello ' f(3) ] );
end
POPUP MENUE
the pop-up contains a menu of items, screen appears with a list of menu items from which to
select. In the following GUI : the popup menu string property considered as array , so
string(1)= 'one' , value = 1
string(2)= 'two' , value = 2
string(3)= 'three' , value = 3

function p1_Callback(hObject, eventdata, handles)


h1=findobj('Tag','p1');
f=get(h1,'string');
v=get(h1,'value');
If get(h1,'Value') == 1
switch get(h1,'Value')
msgbox([ f(1) ' = 1' ] );
case 1
end
msgbox([ f(1) ' = 1' ] );
If get(h1,'Value') == 2
case 2
msgbox([ f(2) ' = 2' ] );
msgbox([ f(2) '= 2' ] );
end
case 3
If get(h1,'Value') == 3
msgbox([ f(3) ' =3' ] );
msgbox([ f(3) ' = 3' ] );
end
end

HW1: Design GUI to select width (1:5) from list box then show its square.
HW2: Design GUI to select Number from (1:10) from popup then show its factorial.

You might also like