Why is uilistbox Multiselect property being ignored inconsistently?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Meade
el 21 de Abr. de 2016
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
el 23 de En. de 2017
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.
Respuestas (0)
Ver también
Categorías
Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!