Small issue with some selection
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Two popup's and one edit text box
First popup
function popupmenu1_Callback(hObject, eventdata, handles)
AUDI = {'Jhon', 'Maria'};
SKODA = {'Jhon', 'Maria', 'Nick'};
MERCEDES = {'Nick'};
% Get car model
selectedCar = handles.popupmenu1.Value;
% Fill owners popup with corresponding list of owners for that model of car.
switch selectedCar
case 1
owners = AUDI;
case 2
owners = SKODA;
case 3
owners = MERCEDES;
end
% Fill owners popup with Audi owners.
str = [];
for k = 1 : length(owners)
str = fprintf('%s\n%s', str, owners{k});
end
handles.edit1.Max = 2; % I think you need this for it to allow a multi-line edit text box.
handles.edit1.String = owners;
Second popup
function popupmenu2_Callback(hObject, eventdata, handles)
AUDI = {'Jhon', 'Maria'};
SKODA = {'Jhon', 'Maria', 'Nick'};
MERCEDES = {'Nick'};
% Get car model
selectedCar = handles.popupmenu2.Value;
% Fill owners popup with corresponding list of owners for that model of car.
switch selectedCar
case 1
owners = AUDI;
case 2
owners = SKODA;
case 3
owners = MERCEDES;
end
% Fill owners popup with Audi owners.
str = [];
for k = 1 : length(owners)
str = fprintf('%s\n%s', str, owners{k});
end
handles.edit1.Max = 2; % I think you need this for it to allow a multi-line edit text box.
handles.edit1.String = owners;
I have a new question for this code
What if ,when I select AUDI and MERCEDES, I want it to show me only if the owners who own both types of cars, if not, to show me message: "no owners who own both types of cars" ? In this case the message will be: no owners who own both types of cars
When I select AUDI and SKODA, I want it to show me only if the owners who own both types of cars , in this case Jhon and Maria.
Thank you!
Antworten (0)
Siehe auch
Kategorien
Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!