select one item between two List Box

조회 수: 5 (최근 30일)
Josep Llobet
Josep Llobet 2021년 9월 13일
댓글: Josep Llobet 2021년 9월 14일
Hi there,
I'm designing an App with MATLAB App designer. I have two Box List, with different items in them. I want the user could select just in a Box List or in a other, but not have two element selected in the two Box List.
I'm looking something like that: (image modified manually, it is not the program)
Thank you!!

채택된 답변

Dave B
Dave B 2021년 9월 13일
편집: Dave B 2021년 9월 13일
How about just using the callback of one to deselect the other:
% Set up some example listboxes:
u = uifigure;
lsta = uilistbox(u,'Items',{'Cat' 'Dog'});
lstb = uilistbox(u,'Items',{'Monkey' 'Horse'});
lsta.Position(2) = sum(lstb.Position([2 4]));
% initial state
lstb.Value = {};
% Changing value of lsta deselects lstb (and vice versa)
lsta.ValueChangedFcn = @(~,~)set(lstb,'Value',{});
lstb.ValueChangedFcn = @(~,~)set(lsta,'Value',{});
  댓글 수: 1
Josep Llobet
Josep Llobet 2021년 9월 14일
That's it
I just desselect the value of one List Box or the other, when the other or one is selected.
% Desseleccionar modificacions guardades
app.ModificacinsguardadesListBox.Value = {};
Thank you @Dave B!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by