How to define row and column of element in grid layout while initializing

8 visualizzazioni (ultimi 30 giorni)
Purely for consolidating. I am creating an extensive UI within a script and it is getting slightly unwieldy having to (1) define grid layout element, (2) specify row, (3) specify column for any element that is not just a 1x1 that is going in the next space.
To illustrate, one of the first examples in this page https://www.mathworks.com/help/matlab/ref/uigridlayout.html has an element they define the row and column of:
% Range drop-down
dd2 = uidropdown(g);
dd2.Items = {'Select a range'};
dd2.Layout.Row = 2;
dd2.Layout.Column = 1;
Can I make this something like this to save space:
dd2 = uidropdown(g,'Items',{'Select a range'},'Layout.Row',2,'Layout.Column',1)
I have tried this and it doesn't work. If this is not possible, what is the point of the 'Layout' option it has in suggestions when creating an element (see screenshot)?

Risposta accettata

Rik
Rik il 12 Mag 2023
Modificato: Rik il 12 Mag 2023
The point you're missing is that the Layout argument is expected to be a struct. Since Layout.Row is not a valid Matlab field name, the syntax you suggested doesn't work.
However, this should work:
dd2 = uidropdown(g,'Items',{'Select a range'},'Layout', struct('Row',2,'Column',1));

Più risposte (0)

Categorie

Scopri di più su Graphics Object Programming in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by