Borrar filtros
Borrar filtros

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

4 visualizaciones (últimos 30 días)
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)?

Respuesta aceptada

Rik
Rik el 12 de Mayo de 2023
Editada: Rik el 12 de Mayo de 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));

Más respuestas (0)

Categorías

Más información sobre Graphics Object Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by