How can I change the state of multiple CheckBoxes in App designer?
4 ビュー (過去 30 日間)
古いコメントを表示
I am working on a GUI that has 200 checkboxes. They have tags like "app.CheckBox_X_Y", where X can have values from 1 to 50 and Y can have values from 1 to 4.
I'd like to change the state of the last checkbox and this must change the state of all others at once.

I tried the following code, but it's giving me error "Error using set - Invalid handle". Can someone help me?
function CheckBoxPelota_X_1ValueChanged(app, event)
if app.CheckBoxPelota_X_1.Value == 0
for cont1 = 1:1:50
for cont2 = 1:1:4
set(sprintf('app.CheckBoxPelota_%d_',cont1),'Value', 1);
end
end
else
for cont1 = 1:1:50
for cont2 = 1:1:4
set(sprintf('app.CheckBoxPelota_%d_',cont1),'Value', 0);
end
end
end
end
0 件のコメント
採用された回答
Voss
2023 年 12 月 21 日
I'll assume that the description, "tags like "app.CheckBox_X_Y", where X can have values from 1 to 50 and Y can have values from 1 to 4", is accurate, that CheckBoxPelota_X_1ValueChanged is the ValueChangedFcn of the top-most "Marcar Todos" checkbox, that that checkbox's tag is CheckBoxPelota_X_1, and that (un)checking it should set the Value of all other checkboxes in the top row to match the Value of app.CheckBoxPelota_X_1 and not effect the checkboxes in the other three rows.
function CheckBoxPelota_X_1ValueChanged(app, event)
val = app.CheckBoxPelota_X_1.Value;
for cont1 = 1:50
set(app.(sprintf('CheckBox_%d_1',cont1)),'Value',val);
end
end
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Develop Apps Using App Designer についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!