GUI: error using set

6 views (last 30 days)
Ignacio Lobato
Ignacio Lobato on 30 Apr 2015
Answered: Jan on 30 Apr 2015
Hi!
I am getting the following error everytime I use the set function in GUI to check/uncheck checkboxes:
Error using set
There is no Value property on the Figure class.
Error in GUI>Selectall_Callback (line 271)
set(handles.check0, 'Value', 1);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in GUI (line 43)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)GUI('Selectall_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
My code is the following:
The opening function (error appears also with the opening function empty, but the error appears in the function selectall, here no error is given)
% --- Executes just before GUI is made visible.
function GUI_OpeningFcn(hObject, eventdata, handles, varargin)
% Choose default command line output for GUI
handles.output = hObject;
set(handles.check0, 'Value', 0);
set(handles.check5, 'Value', 0);
set(handles.check10, 'Value', 0);
set(handles.check15, 'Value', 0);
set(handles.check20, 'Value', 0);
set(handles.check25, 'Value', 0);
set(handles.check30, 'Value', 0);
% Update handles structure
guidata(hObject, handles);
And the button to check all boxes (error appears when I press this button)
function Selectall_Callback(hObject, eventdata, handles)
set(handles.check0, 'Value', 1);
set(handles.check5, 'Value', 1);
set(handles.check10, 'Value', 1);
set(handles.check15, 'Value', 1);
set(handles.check20, 'Value', 1);
set(handles.check25, 'Value', 1);
set(handles.check30, 'Value', 1);
Thanks for your help!!
  1 Comment
Adam
Adam on 30 Apr 2015
Edited: Adam on 30 Apr 2015
Have you double-checked the tags of your checkboxes in GUIDE?
For some reason that isn't immediately obvious to me the code seems to think that handles.check0 is a figure object rather than a checkbox.
I have sometimes got tangled up in the past with GUIDE-created GUIs but usually if I do something like incorrectly editing a previously automated callback or renaming the GUI file.
Editing the GUI while still in a debug session on the same GUI also causes a mess from which I usually have to cancel all my GUI changes since the last save.

Sign in to comment.

Answers (1)

Jan
Jan on 30 Apr 2015
Check the code, if the variable handles.check0 is set to the figure handle anywhere. If the OpeningFcn runs successfully, this variable must be correct, but later on the contents must have been changed.

Categories

Find more on Migrate GUIDE Apps 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!