ListBox callback error

2 views (last 30 days)
Adam on 11 Feb 2012
Edited: Image Analyst on 21 Oct 2013
Hi, do not know where I made a mistake? Thank you very much.
??? Undefined variable "handles" or class "handles.ListBox".
Error in ==> dilist> dilist_callback at 23
fname = get (handles.ListBox, 'String');
??? Evaluating Error while uicontrol Callback
function dilist
h1 = figure;
handles.ListBox = uicontrol ('Units', 'Normalized', 'Position', [0.01 0.1 0.1 0.15], ...
'Style', 'List', 'Callback', @ dilist_callback);
P = fileparts (mfilename ('fullpath'));
nfolder uigetdir = (P, 'whatever');
handles.dfolder = nfolder;
dfiles = dir (handles.dfolder);
dfiles dfiles = (3: end);
nfiles = length (dfiles);
nfiles if <1
disp ('no files availabel.')
set (handles.ListBox, 'String', char (, 'value', 1);
s = [num2str (nfiles) 'files in:' handles.dfolder];
dilist_callback function (src, evt)
fname = get (handles.ListBox, 'String');
fname = fname (get (handles.ListBox, 'value'), :);
dicominfo info = ([handles.dfolder '\' fname]);
Y1 = dicomread (info);
imshow (Y1)
clims = [10 1800];
  1 Comment
Walter Roberson
Walter Roberson on 11 Feb 2012
duplicate is at

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 11 Feb 2012
After the line
handles.ListBox = [...]
guidata(h1, handles);
Change the line
dilist_callback function (src, evt)
function dilist_callback (src, evt)
In the line immediately after that add
handles = guidata(ancestor(src),'figure');
Tannistha on 23 Feb 2012
try this
set (handles.ListBox, 'String', {}, 'value', 1)

Sign in to comment.


Find more on File Operations 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!