dealing with checkbox in GUI

7 ビュー (過去 30 日間)
geeks g
geeks g 2019 年 5 月 17 日
編集済み: Adam Danz 2019 年 5 月 17 日
i have a uipanel
inside of it a 20 checkboxes , iwant to push a button 'clear' and make all the checboxes un checked
how can i do it??
  4 件のコメント
geeks g
geeks g 2019 年 5 月 17 日
SO I HAVE this ui table i want to select sujects and push 'submit' to calculate the sum of credit for the subject i selected
i dont know how to dealing with uitable to get data from it and calculat the sum
and after that i want to push a clear' button to reset all
help please
Adam Danz
Adam Danz 2019 年 5 月 17 日
編集済み: Adam Danz 2019 年 5 月 17 日
Duplicate
@geeks g , see your other question (link above) for a response.

サインインしてコメントする。

採用された回答

Dennis
Dennis 2019 年 5 月 17 日
Use a loop and uncheck/check them.
%create 20 checkboxes
for i=20:-1:1
handles.uihandles(i)=uicontrol('style','checkbox','position',[100 600-i*25 20 20]);
end
set(gcf, 'Position', get(0, 'Screensize'));
%create 1 pushbutton
uicontrol('style','pushbutton','string','check all','position',[200 600 80 40],'callback',{@check_all_callback,handles});
function check_all_callback(~,~,handles)
if handles.uihandles(1).Value==1 %if the last checkbox is checked, uncheck all
for i=1:20
handles.uihandles(i).Value=0;
end
else
for i=1:20
handles.uihandles(i).Value=1; %if the last checkbox is unchecked, check them all
end
end
end
If you are using guide/appdesigner your handles will not be indexed as in my example. In that case use sprintf to construct handle names.
  1 件のコメント
geeks g
geeks g 2019 年 5 月 17 日
thank you

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDialog Boxes についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by