App Designer ListBox.Value working strangely?
Show older comments
Hi all!
I encountered the following problem: I tried to import file names from 2 different folders to 2 listboxes. Until this the code works. But then I tried to add the selected items from the respective lists to another 2 lists. So until this the code should be totally the same.
But in one version the ListBox.Value is a string and in the other is a cell array, and I haven't been able to find the cause.
Does anybody have an explanation for this phenomenon or it is just a bug?
The code:
if true
% code
end
searchpath = (['\\xxx\yyy\zzz\' app.TabSelect])
listmeasdata = dir(searchpath)
dirFlags = [listmeasdata.isdir]
files = {listmeasdata(~dirFlags).name}
if app.TabGroup.SelectedTab == app.xTab
app.xListListBox.Items = files
else app.TabGroup.SelectedTab == app.yTab
app.yListListBox.Items = files
end
function TabGroupSelectionChanged(app, event)
if app.TabGroup.SelectedTab == app.xTab
app.TabSelect = 'x'
end
if app.TabGroup.SelectedTab == app.yTab
app.TabSelect = 'y'
% Button pushed function: xAddtoselectionButton
function xAddtoselectionButtonPushed(app, event)
lastelement = numel(app.xSelectedListBox.Items)
app.xSelectedListBox.Items(lastelement+1) = {app.xListListBox.Value}
% Button pushed function: yAddtoselectionButton
function yAddtoselectionButtonPushed(app, event)
lastelement = numel(app.ySelectedListBox.Items)
app.ySelectedListBox.Items(lastelement+1) = app.yListListBox.Value
You can see my problem in the first and fifth row from the bottom. Neither
- app.xSelectedListBox.Items(lastelement+1) = app.xListListBox.Valueor
- app.ySelectedListBox.Items(lastelement+1) = {app.yListListBox.Value}works
Accepted Answer
More Answers (0)
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!