populate a listbox with selected folder doc file names - App designer

16 ビュー (過去 30 日間)
Ely Raz
Ely Raz 2020 年 8 月 10 日
編集済み: Adam Danz 2020 年 8 月 11 日
How can I populate a listbox with all doc files in a selected folder using a button in App designer?
function selectDocButtonPushed(app, event)
app.selectedPath = uigetdir();
docFileInfo = dir('*.doc')
app.docListBox.Items = docFileInfo.name
end

採用された回答

Adam Danz
Adam Danz 2020 年 8 月 10 日
編集済み: Adam Danz 2020 年 8 月 10 日
Give this a shot,
docFileInfo = dir(fullfile(app.selectedPath, '*.doc'));
app.docListBox.Items = {docFileInfo.name}';
  4 件のコメント
Ely Raz
Ely Raz 2020 年 8 月 10 日
Thank a lot. I meant how can I store the one file which is marked/selected in the listbox?
Adam Danz
Adam Danz 2020 年 8 月 10 日
編集済み: Adam Danz 2020 年 8 月 11 日
Here's what you need to know about the listbox.
1) app.ListBox.Items stores what you seein the list.
2) app.ListBox.ItemsData is used to store optiona info about each item in the list. This is what is returned when you fetch the currently selected item.
3) app.ListBox.Value returns the currently selected ItemsData.
So, what I recommend is to store the file names in Items and the full paths in ItemsData. Then, to get the full path of the selected item, you just need to access the Value property.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by