필터 지우기
필터 지우기

displaying contents in a list bx after button press

조회 수: 3 (최근 30일)
Gurvinder
Gurvinder 2013년 8월 18일
Hi I have a GUI, in which i press a button and it obtains all he file names from my database. I then want this to be displayed within a list box but can't get the list box to update can someone help please?
here is my code so far:
% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global str;
str = getfilenames;
disp(str);
% --- Executes during object creation, after setting all properties.
function listbox1_CreateFcn(hObject, eventdata, handles)
% hObject handle to listbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
global str;
set(hObject, 'String', str2 );

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 8월 18일
Your code is not clear for me, but I see that you are creating a list in the listbox callback while you should do it in the push button callback
  댓글 수: 2
Gurvinder
Gurvinder 2013년 8월 18일
Sorry here you go
function pushbutton7_Callback(hObject, eventdata, handles) global str;
str = getfilenames;
disp(str);
the above push button in my gui is calling another function i made to obtain all the file names.
I want it to update my listbox below once i click the button but don't know how...code for list box below:
function listbox1_CreateFcn(hObject, eventdata, handles) global str;
set(hObject, 'String', str2 );
could you provide an example of what you mean or know of any documentation that i could read to help?
Azzi Abdelmalek
Azzi Abdelmalek 2013년 8월 18일
편집: Azzi Abdelmalek 2013년 8월 18일
Use
function pushbutton7_Callback(hObject, eventdata, handles)
str = getfilenames;
set(handles.listbox1, 'String', str );

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by