You will get that error message if you had one folder and had, say, the 10'th item in the listbox selected. Then if you went to another folder and called LoadImageList() and that folder only had, say, 5 images. The listbox would still have a "value" property of 10 but there are only 5 items there. It can't select the 10th item, so it throws that warning message.
What you need to do is to add something like this after the for loop
if length(ListOfImageNames) >= 1
set(handles.lstImageList, 'value', 1);
else
set(handles.lstImageList, 'value', []);
end
Best Answer