MATLAB Answers

GUI : uicontrol values

12 views (last 30 days)
Clément P
Clément P on 1 Apr 2016
Commented: Clément P on 1 Apr 2016
Hi everyone,
I have a GUI with several check boxes/togglebuttons/Pushbutton. I want to set the value to 0 of all the uicontols when I push one other. Is there a way to do it either than putting every value to 0.
Currently, I have this code at the beginning of all my callbacks function :
set(handles.tb1,'Value',0);
set(handles.tb2,'Value',0);
set(handles.tb3,'Value',0);
set(handles.box1,'Value',0);
set(handles.box2,'Value',0);
set(handles.box3,'Value',0);
set(handles.box4,'Value',0);
set(handles.box5,'Value',0);
It's working, but it's making my code very long and hard to read.
Thanks, Clément

  0 Comments

Sign in to comment.

Accepted Answer

Orion
Orion on 1 Apr 2016
Hi,
one way is using findall :
% set all the checkboxes of the current figure to 0 :
set(findall(gcf,'Style','Checkbox'),'Value',0)
% same for togglebuttons
set(findall(gcf,'Style','togglebutton'),'Value',0)

  1 Comment

Clément P
Clément P on 1 Apr 2016
Perfect, I always forgot this function :D

Sign in to comment.

More Answers (0)

Sign in to answer this question.


Translated by