MATLAB Answers

If I change the folder names in the popup menu and i need to get the files in that folder to the list box and similar if i change to other folder , that folders files should come

5 views (last 30 days)
KATARI LOKESH
KATARI LOKESH on 1 Jul 2020
Commented: Rik on 1 Jul 2020
  1. I am not clear how to change files in list box w.r.t that folder
Kindly please help me with this
Thanks
Lokesh

  0 Comments

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 1 Jul 2020
ph = handles.YourPopup;
lh = handles.YourListbox;
selection_index = ph.Value;
if ~isempty(selection_index)
user_chosen_folder = ph.String{selection_index};
dinfo = dir(user_chosen_folder);
dinfo([dinfo.isfolder]) = []; %only want file names
filenames = {dinfo.name}; %names of the files
lh.String = filenames; %put the names in the listbox
drawnow()
end

  4 Comments

Show 1 older comment
Rik
Rik on 1 Jul 2020
It is the Value of your popop menu, so it is the index of your selection in that popup menu. So if you have selected the second item it will be 2, if you selected the 5th item it will be 5, etc.
KATARI LOKESH
KATARI LOKESH on 1 Jul 2020
Hi Rik,
I am very new to this, can you write a small example which two folders in popmenus and files in the list box.
Please help me with this
Thank you so much
Lokesh
Rik
Rik on 1 Jul 2020
Why don't you try the code that Walter gave you? If you don't understand a function, try reading the documentation. You asked what a specific variable meant, I explained it. If you don't understand the explanation, please say so, because giving you a code example will not help explaining what that value means.

Sign in to comment.

More Answers (0)

Products


Translated by