ListBox error - existent field

1 次查看(过去 30 天)
Hi I have a problem, I wanted to let the selected folder names DICOM file appears in the listbox. But Hals me an error:
??? References to non-existent field 'ListBox'.
Error in ==> load at 35
set (handles.ListBox, 'String', char (dfiles.name), 'value', 1);
Does anybody know how to do it? Thank you very much.
h1=figure;
ListBox=uicontrol('Units','Normalized','Position',[0.01 0.1 0.1 0.15],...
'Style','List');
P=fileparts(mfilename('fullpath'));
nfolder=uigetdir(P,'cokoliv');
handles.dfolder=nfolder;
handles.dfolder=nfolder;
dfiles=dir(handles.dfolder);
dfiles=dfiles(3:end);
set(handles.ListBox,'String',char(dfiles.name),'value',1);
fname=get(handles.ListBox,'String');
fname=fname(get(handles.ListBox,'value'),:);
img=dicomread([dfolder '\' fname]);
imagesc(img);

采纳的回答

Sean de Wolski
Sean de Wolski 2012-2-8
handles =
dfolder: 'H:\Documents\MATLAB'
It does not have a field ListBox. You can either make listbox a field
handles.ListBox = uicontrol(...
Or call get/set directly with ListBox
get(ListBox,'...
  1 个评论
Adam
Adam 2012-2-8
Great, thank you. I missed that detail (handles) before uicontrol. Thank you very much.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by