Borrar filtros
Borrar filtros

MATLAB R2017b UIListBox possible bug (ItemsData)

7 visualizaciones (últimos 30 días)
Liron Stettiner
Liron Stettiner el 16 de Sept. de 2019
Respondida: Manas Meena el 30 de Sept. de 2020
Hello, My name is Liron. I use MATLAB R2017b.
I’m currently working on an App Designer GUI, in which I use a UIListBox and assign data to each Item in the list. The three properties related to my bug/issue are ‘Value’, ‘Items’ and ‘ItemsData’. As far as I know:
The ‘Items’ property is a cell/string Array which determines the titles of the user’s possible choices.
The ‘Value’ property is the current chosen Item, highlighted in blue. Obviously, This ‘Value’ has to be the same as one of the ‘Items’.
The ‘ItemsData’ property is a 1-n cell/double array (where n = length(Items)) which allows us to assign additional, hidden data to each item in the list.
PROBLEM: After setting ‘ItemsData’ to be anything else than an empty array, MATLAB mistakenly thinks the ‘Value’ is supposed to be one of the values of the ’ItemsData’(!) array, instead of the ‘Items’ array. In my specific case I’ve set the following:
% BEFORE ASSIGNING THE ‘ITEMSDATA’ PROPERTY:
>> App.nameListBox.ItemsData -> {} % check
>> App.nameListBox.Items = {‘option 1’};
>> App.nameListBox.Value = ‘option 1’; % Works good
% ASSIGNING THE ‘ITEMSDATA’ PROPERTY:
>> S = struct;
>> S.a = 1; % For instance
>> App.nameListBox.ItemsData = S;
>> App.nameListBox.Items -> {‘option 1’} % check
>> App.nameListBox.Value -> (the struct, S, even though I haven’t changed the ’Items’ property at all).
Does anyone have any idea why this happens? Is this a bug of this version of MATLAB? Have I done something wrong? Any suggestions?
Thank you very much. Sincerely, Liron Stettiner

Respuesta aceptada

Manas Meena
Manas Meena el 30 de Sept. de 2020
The ListBox is working as intended and this is not a bug. It is a defined property of ListBox which states that If ItemsData is not empty, then Value must be set to an element of ItemsData, and the list box will select the associated item in the list.”
You may refer to the documentation link below to learn more about the ListBox, Properties which control the appearance and behaviour of a ListBox.

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Productos


Versión

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by