WinUI コントロール
サイズ設定
コントロール > FlexGrid > > サイズ設定

Set row height

FlexGrid provides the DefaultSize property of GridRowColCollection<T> class to set the default row height across the grid. You can also specify the width of a particular column by setting the Height property of GridRow class.

Use the code below to set the row height of all rows and a particular row of the FlexGrid.

C#
コードのコピー
// 行の高さ(すべての行)を設定します
flexGrid1.Rows.DefaultSize = new GridLength(40);
// 行の高さ(特定の行)を設定します
flexGrid1.Rows[2].Height = new GridLength(120);

Auto adjust row height

To adjust the row height according to the text length, FlexGrid provides the Height property of GridRow class. To enable auto-adjust row height, set the GridLength struct to Auto. The GridLength struct is used to represent a measurement for control logic that explicitly supports **Star** (`*`) sizing and **Auto** sizing.

Following code shows how you can auto adjust the row heights according to the text length in the FlexGrid.

C#
コードのコピー
// 行の高さを自動調整します
flexGrid1.Rows[0].Height = GridLength.Auto;

Set min/max row height

FlexGrid allows you to set bounds to the column width by using the MinHeight and MaxHeight properties of GridRow class.

Specify the bounds of row height in the FlexGrid using the code below.

C#
コードのコピー
// 最小行の高さを設定します
flexGrid1.Rows[3].MinHeight = 100;
// 最大行の高さを設定します
flexGrid1.Rows[3].MaxHeight = 250;