How to define row and column of element in grid layout while initializing
6 ビュー (過去 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)?
0 件のコメント
採用された回答
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 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!