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
Best Answer