필터 지우기
필터 지우기

Is it possible to disable the items of listbox using m-scripting?

조회 수: 7 (최근 30일)
Afifa Shaikh
Afifa Shaikh 2020년 10월 23일
답변: Image Analyst 2020년 10월 23일
I want to disable the items of listbox after a particular string is found in the listbox item.
Is there any way to disable the items?

답변 (1개)

Image Analyst
Image Analyst 2020년 10월 23일
Yes, in the listbox click event, just immediately disable (deselect) any item that you don't want clicked on by removing it from the list of items they clicked on and sending the new selection(s) back to the listbox control. For example, in GUIDE:
% Retrieve what items were selected by the user.
selectedItems = handles.lstListbox.Value;
% See if item #3 was selected.
protectedIndex = selectedItems == 3;
% If 3 was selected, disable/deselect it.
if any(protectedIndex)
% Remove from the selection array variable.
selectedItems(protectedIndex) = []
% Update listbox with new selection.
handles.lstListbox.Value = selectedItems;
end

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by