Why is uilistbox Multiselect property being ignored inconsistently?
조회 수: 3 (최근 30일)
이전 댓글 표시
I am using the new App Designer in 2016a and have created a uilistbox. The Multiselect property is set to 'on'. When running with a debug flag set multi-selection works, when running normally multi-selection does not work. What is driving this behavior? Are there any workarounds or solutions?
Auto generated code that creates the list box:
app.DaysimeterList = uilistbox(app.HomeTab);
app.DaysimeterList.Items = {'proto 1', 'proto 2'};
app.DaysimeterList.Multiselect = 'on';
app.DaysimeterList.ValueChangedFcn = createCallbackFcn(app, @DaysimeterListValueChanged);
app.DaysimeterList.Position = [526 83 100 299];
app.DaysimeterList.Value = {'proto 1'};
Code that updates the list and is supposed to select all items:
function results = refreshDaysimeterList(app)
daysimeterPaths = app.getDaysimeters;
deviceSns = cellfun(@app.getDeviceSn,daysimeterPaths,'UniformOutput',false);
app.DaysimeterList.Items = deviceSns';
app.DaysimeterList.ItemsData = daysimeterPaths';
if isempty(daysimeterPaths)
app.DaysimeterList.Enable = 'off';
app.DaysimeterList.Items = {'None'; 'detected'};
else
app.DaysimeterList.Enable = 'on';
app.DaysimeterList.Value = app.DaysimeterList.ItemsData(:); % Select all Daysimeters
end
end
The update function is called during the App startup:
% Code that executes after component creation
function startupFcn(app)
app.loadPreferences; % Load the App preferences
app.refreshDaysimeterList; % Refresh the Daysimeter list
end
댓글 수: 3
Meade
2016년 4월 21일
The "Value" method is usually indices, but you're trying to assign it whatever format "ItemsData" is in.
Try changing the last line in your refreshDaysimeterList fnc.
app.DaysimeterList.Value = 1:numel(app.DaysimeterList.ItemsData); % Select all Daysimeters
Does this change your result?
Greg
2017년 1월 23일
The comment by Meade is completely off the mark. AppDesigner documentation clearly states that the 'Value' property is a value of the 'ItemsData' property, or of 'Items' if 'ItemsData' is empty.
답변 (0개)
참고 항목
카테고리
Help Center 및 File 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!