Listbox multi selection without using Ctrl?
古いコメントを表示
Hi All
I have a GUIDE listbox in which I select and deselect multiple options regularly. Listbox entry selection unfortunately works like Windows file selection in Explorer; You have to hold down Ctrl if you want to deselect only one file in a selection or want to add one. Can I set the listbox to rather toggle clicked entries? When my customer forgets to hold down Ctrl, all their selections disappear...
Thanks!
採用された回答
その他の回答 (2 件)
Have you considered putting multiple checkboxes or toggle buttons inside of a button group instead? It sounds like that might be closer to the behavior you're describing.
3 件のコメント
Jurgens Wolfaardt
2018 年 1 月 9 日
Rohit Deshmukh
2019 年 12 月 12 日
@Jurgens-
I am looking for same solution. How did you implement radio buttons in list box?
Walter Roberson
2019 年 12 月 12 日
You cannot have a radio button inside a list box. You would use a uibuttongroup
Also note that by definition a radio button group has exactly one selection (or sometimes none) which would be the opposite of the requirement of the Question which inherently requires multiple selection.
Harry Weston
2023 年 11 月 23 日
編集済み: Walter Roberson
2023 年 11 月 25 日
I got the following to work for selecting multiple values on an app listbox:
% check if the value is already selected and remove if it has
if max(contains(app.selectedYChannels, app.YChannelsListBox.Value))
% remove
valToRemove = contains(app.selectedYChannels, app.YChannelsListBox.Value);
app.selectedYChannels{1,valToRemove} = [];
app.selectedYChannels = app.selectedYChannels(~cellfun('isempty',app.selectedYChannels));
else
% save stored selection
app.selectedYChannels = [app.selectedYChannels, app.YChannelsListBox.Value];
end % if
% update Y Channel/s list box
app.YChannelsListBox.Value = app.selectedYChannels;
1 件のコメント
Walter Roberson
2023 年 11 月 25 日
I would suggest that it would be clearer if you changed
if max(contains(app.selectedYChannels, app.YChannelsListBox.Value))
to
if any(contains(app.selectedYChannels, app.YChannelsListBox.Value))
カテゴリ
ヘルプ センター および File Exchange で Interactive Control and Callbacks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!