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

7 次查看(过去 30 天)
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)?

采纳的回答

Rik
Rik 2023-5-12
编辑:Rik 2023-5-12
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));

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 App Building 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by