Reset button

조회 수: 7 (최근 30일)
Maryam Emad
Maryam Emad 2011년 12월 13일
Welcome All...
I have GUI with multiple Edit( To Get User Input ).
I wish to ADD Reset Pushbutton in order to clear All input.
How I can do it ?

채택된 답변

Dr. Seis
Dr. Seis 2011년 12월 13일
You will have to hard-code this functionality. You will need to create a pushbutton and then under that new pushbutton function you will have to use "set" to restore all your edit boxes back to blank space or a default value. I.e.,
set(handles.my_edit_box,'String','');
or
set(handles.my_edit_box,'String','some_default_value');
  댓글 수: 2
Paul Peeling
Paul Peeling 2011년 12월 13일
If there are a lot of edit boxes, you could set the Tag property on each edit box and use FINDOBJ to change the value of all these controls
Walter Roberson
Walter Roberson 2011년 12월 13일
Well, findobj to locate the boxes whose String is to be set
set(findobj('Tag','ResetAllowed'),'String',{''})
This will, however, not work if you are using GUIDE, as GUIDE uses the Tag property for other things.

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

추가 답변 (2개)

Paulo Silva
Paulo Silva 2011년 12월 13일
set(findobj(0,'style','edit'),'string','') %put this in the button callback
%that should clear all edit uicontrols
or
set(findobj(handles.figure1,'style','edit'),'string','')
%should only clear the edit uicontrols from the current GUI
  댓글 수: 3
Maryam Emad
Maryam Emad 2011년 12월 13일
I try to do like this
set(findobj(handles.figure1,'style','edit','popupmenu'),'string','')
But it make an error !
Walter Roberson
Walter Roberson 2011년 12월 13일
set(findobj(handles.figure1,'style','edit', '-or', 'style','popupmenu'),'string','')

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


Maryam Emad
Maryam Emad 2011년 12월 13일
Thanks .. Elige Grant & Paul Peeling
Grateful to you :)
OK..
What About this code , How do I take advantage of it ?
closeGUI = handles.figure1; %handles.figure1 is the GUI figure
% guiPosition = get(handles.figure1,'Position'); %get the position of the GUI
% guiName = get(handles.figure1,'Name'); %get the name of the GUI
% eval(guiName) %call the GUI again
%
% close(closeGUI); %close the old GUI
% set(gcf,'Position',guiPosition); %set the position for the new GUI

카테고리

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