Decrease Existing UIGridLayout RowHeight (or ColumnWidth)

9 vues (au cours des 30 derniers jours)
Calvin Bitakis
Calvin Bitakis le 12 Août 2022
Réponse apportée : Amith le 17 Juil 2024
I'm trying to decrease an existing uigridlayout's number of rows and columns. Below I created the figure and grid.
fig = uifigure; % make uifigure
g = uigridlayout(fig); % put uigridlayout in fig
g.RowHeight = {'1x' '1x' '1x' '1x'}; % assign to uigridlayout 4 rows
g.ColumnWidth = {'1x' '1x'}; % assign to uigridlayout 2 columns
So, it already exists and has a specified row height and column width dimensions. And I want to change the number of rows and columns in this existing uigridlayout (g)... instead of deleting it and making a new one with the desired number of rows and columnns (e.g. a grid with 3 rows and 3 columns).
I am able to add rows or columns -->
g.ColumnWidth = {'1x' '1x' '1x'} % assign greater amount of columns to g.ColumnWidth property
output -->
g =
GridLayout with properties:
RowHeight: {'1x' '1x' '1x' '1x'}
ColumnWidth: {'1x' '1x' '1x'}
But I can't seem to be able to remove rows or columns -->
g.RowHeight = {'1x' '1x' '1x'} % assign lower amount of columns to g.RowHeight property
output -->
g =
GridLayout with properties:
RowHeight: {'1x' '1x' '1x' '1x'}
ColumnWidth: {'1x' '1x' '1x'}
How do I decrease the number of rows or columns in this existing uigridlayout?

Réponses (1)

Amith
Amith le 17 Juil 2024
Hi Calvin,
According to the MathWorks GridLayout properties documentation ( https://www.mathworks.com/help/matlab/ref/matlab.ui.container.gridlayout-properties.html), altering certain aspects of a layout can impact the value of this property. For instance, adding more components to a fully populated grid will adjust the grid size to accommodate the new components.
Modifying the ColumnWidth property in a grid layout that already contains components does not change the layout of those components. For example, if you attempt to dynamically delete a column that contains components, the ColumnWidth property will not change until you relocate those components out of that column.
The same principles apply to the RowHeight property as well.
Hope this helps!

Catégories

En savoir plus sur Develop uifigure-Based Apps dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by