Filter löschen
Filter löschen

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

3 Ansichten (letzte 30 Tage)
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

Akzeptierte Antwort

Voss
Voss am 21 Dez. 2023
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

Weitere Antworten (0)

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by