Creating a Checkbox depending on another Checkbox [GUI]
2 views (last 30 days)
Show older comments
Hi,
i have to checkboxes. Since the second checkbox activates an additional action to the first checkbox, it must not be "clickable" until the first checkbox is checked.
-> only two possible scenarios: first checked, or both checked.
Is that possible?
I dont think its necessary, but to be more specific:
The first checkbox creates a 3d plot, and the second one creates and saves an adequate fig-file.
Thanks a lot for helping!
0 Comments
Answers (1)
Geoff Hayes
on 13 Aug 2016
mec123 - suppose that you have two checkboxes, checkbox1 and checkbox2, with the latter being enabled only if checkbox1 is checked. To disable the second one, in the OpeningFcn of your GUI you would do
function myGui_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
set(handles.checkbox2,'Enable','off');
Then in the callback for your first checkbox, you would do
function checkbox1_Callback(hObject, eventdata, handles)
if get(hObject,'Value') == 1
set(handles.checkbox2,'Enable','on');
else
set(handles.checkbox2,'Value',0,'Enable','off');
end
If checkbox1 is checked (and so its Value property is set to one) then we enable the other checkbox. Else if checkbox1 is unchecked (and so its Value property is set to zero) then we clear the checked state of checkbox2 and disable it.
0 Comments
See Also
Categories
Find more on Annotations 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!