フィルターのクリア

How can I change the state of multiple CheckBoxes in App designer?

3 ビュー (過去 30 日間)
Rafael Campos
Rafael Campos 2018 年 10 月 27 日
回答済み: Voss 2023 年 12 月 21 日
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

採用された回答

Voss
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 件)

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by