Edit box in Gui app

14 views (last 30 days)
Wiktoria Glogowska
Wiktoria Glogowska on 24 Jul 2019
I am working on an app in GUIDE matlab. I want to display some information (1st cell in a field of a structure) in an editbox in the main figure of GUI. I was using the followinf code, which doesn't work (no change to the edit text box):
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.edit1 = edit1;
guidata(hObject, handles)
(I suspect that I might be using the handles wrong but I am not sure. Could somebody point me in the right direction? ) How do I update the edit box?

Accepted Answer

Dennis on 24 Jul 2019
Do you get any error messages?
You are overwriting the handle of your edit box, thus you use the wrong handle when you try to update it:
handles.edit1 = edit1; % this should throw an error unless you have an edit1 function somewhere
edit1=handles.edit1; %this would be okayish, but not necessary
I am not aware of any cell2str function. Here is a small example what might work:
function edit1_cb(hObj,~,handles)
%set(hObj,'string',num2str(handles.MyData{1})) %this would work aswell
Dennis on 24 Jul 2019
In that case you can simply change the text of the edit field inside the callback that loads your data.
Wiktoria Glogowska
Wiktoria Glogowska on 24 Jul 2019
Thanks for help!!

Sign in to comment.

More Answers (0)


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!