[GUI] How do you get only one element in a listbox
1 回表示 (過去 30 日間)
古いコメントを表示
I know you are able to obtain all the elements in a string from the listbox with:
get(handles.listbox1, 'String')
But what if I only want the second or fourth element in the listbox?
Thanks in advance <3
0 件のコメント
採用された回答
Image Analyst
2012 年 12 月 17 日
You have to read in the whole thing anyway. Then get the value property and use that to index into the string.
listboxItems = get(handles.listbox1, 'string');
selectedItems = get(handles.listbox1, 'value');
selectedItem = listboxItems(selectedItems);
4 件のコメント
Walter Roberson
2012 年 12 月 17 日
Change
listboxItems = get(handles.listbox1, 'string');
to
listboxItems = cellstr( get(handles.listbox1, 'string') );
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Migrate GUIDE Apps についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!