Filters in pop up menu

1 次查看(过去 30 天)
Basanagouda Kenchanagoudra
回答: VBBV 2024-3-29
I have code which reads Test.csv data into GUI into two pop up menus like below.
The code I have used is
My requirement is,
1.) Wanted to get only Bus companies in the Register pop up menu when Bus is selected Module pop up menu
Right now, all the items are coming in Register pop up menu when I select anything in Module pop up menu.
Its like adding filters in the excel file.
Can anyone help me here??
Thanks in advance

回答(1 个)

VBBV
VBBV 2024-3-29
Hi @Basanagouda Kenchanagoudra, You can use switch-case inside the Callback as shown below
Item = get(handles.Module_PopUp,'String') % get the unique list of items
ItemV = get(handles.Module_PopUp,'Value') % get the value of item selected in popupmenu
switch Item{ItemV} % use a swtich case for filtering items
case 'Bike'
idx = find(get_module_names == "Bike"); % search for similar items /bike
set(handles.Reg_PopUp,'String',get_reg_names(idx));
case 'Car'
idx = find(get_module_names == "Car") % search for similar items /car
set(handles.Reg_PopUp,'String',get_reg_names(idx));
case 'Bus'
idx = find(get_module_names == "Bus"); % search for similar items /bus
set(handles.Reg_PopUp,'String',get_reg_names(idx));
end

类别

Help CenterFile Exchange 中查找有关 Data Import from MATLAB 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by