Class GridLayout
A layout panel that arranges child elements in a sophisticated grid structure with configurable rows, columns, spanning, and advanced sizing modes.
Inherited Members
Namespace: Telerik.WinControls.Layouts
Assembly: Telerik.WinControls.dll
Syntax
public class GridLayout : LayoutPanel, IDisposable, INotifyPropertyChanged, ICustomTypeDescriptor, ISupportSystemSkin, IStylableNode
Remarks
GridLayout provides comprehensive grid-based layout capabilities that rival modern CSS Grid and HTML table functionality. It supports column and row definitions with multiple sizing modes including proportional sizing, fixed pixel dimensions, auto-sizing based on content, and star-sizing for flexible space distribution.
Advanced features include:
- Row and column spanning for elements that need to occupy multiple grid cells
- Individual cell padding control for precise element positioning within cells
- Proportional sizing with star notation for responsive column and row widths
- Auto-sizing columns and rows based on their content requirements
- Stretch modes for filling available horizontal and vertical space
- DPI-aware scaling for consistent appearance across different display densities
GridLayout is extensively used for creating complex, table-like layouts such as forms, data entry screens, dashboard layouts, property grids, and any UI where precise row and column control with responsive behavior is required. The layout system automatically handles cell positioning, sizing calculations, and element arrangement based on the defined grid structure and content requirements.
Constructors
GridLayout()
Initializes a new instance of the GridLayout class with a single cell (1x1 grid).
Declaration
public GridLayout()
Remarks
GridLayout(Int32, Int32)
Initializes a new instance of the GridLayout class with the specified number of columns and rows.
Declaration
public GridLayout(int columnsCount, int rowsCount)
Parameters
System.Int32
columnsCount
The number of columns to create in the grid. Must be greater than 0. |
System.Int32
rowsCount
The number of rows to create in the grid. Must be greater than 0. |
Remarks
This constructor creates a grid layout with the specified dimensions, where all columns and rows are initialized with default sizing behavior. Each column will use automatic sizing unless explicitly configured through the Columns collection, and similarly for rows through the Rows collection.
This is the most efficient way to create a grid when you know the required dimensions in advance, as it pre-allocates the internal collections and avoids dynamic resizing during layout operations.
Fields
CellPaddingProperty
ColSpanProperty
ColumnIndexProperty
RowIndexProperty
RowSpanProperty
Properties
Columns
Gets or sets the collection of column definitions that determine the width and sizing behavior of grid columns.
Declaration
public List<GridLayoutColumn> Columns { get; set; }
Property Value
System.Collections.Generic.List<GridLayoutColumn>
A System.Collections.Generic.List<T> of GridLayoutColumn objects that define the grid's column structure. |
Remarks
Each GridLayoutColumn in this collection represents a column in the grid and provides configuration for width sizing behavior including:
- Fixed pixel widths for precise column sizing
- Proportional star-sizing for flexible width distribution
- Auto-sizing based on column content requirements
Modifying this collection triggers layout invalidation and re-measurement to accommodate the new column structure. The column index of child elements should correspond to valid indices within this collection.
Rows
Gets or sets the collection of row definitions that determine the height and sizing behavior of grid rows.
Declaration
public List<GridLayoutRow> Rows { get; set; }
Property Value
System.Collections.Generic.List<GridLayoutRow>
A System.Collections.Generic.List<T> of GridLayoutRow objects that define the grid's row structure. |
Remarks
Each GridLayoutRow in this collection represents a row in the grid and provides configuration for height sizing behavior including:
- Fixed pixel heights for precise row sizing
- Proportional star-sizing for flexible height distribution
- Auto-sizing based on row content requirements
Modifying this collection triggers layout invalidation and re-measurement to accommodate the new row structure. The row index of child elements should correspond to valid indices within this collection.
Methods
ArrangeOverride(SizeF)
Declaration
protected override SizeF ArrangeOverride(SizeF finalSize)
Parameters
System.Drawing.SizeF
finalSize
|
Returns
System.Drawing.SizeF
|
Overrides
DpiScaleChanged(SizeF)
Handles DPI scaling changes by invalidating layout measurements and updating the grid structure.
Declaration
public override void DpiScaleChanged(SizeF scaleFactor)
Parameters
System.Drawing.SizeF
scaleFactor
The scaling factor applied due to DPI changes. |
Overrides
Remarks
This method ensures that the grid layout responds appropriately to DPI changes by:
- Invalidating existing measurements to force recalculation with new DPI
- Triggering a complete layout update to apply DPI-scaled dimensions
- Ensuring fixed-size columns and rows are properly scaled
This maintains visual consistency and proper proportions when the application is moved between displays with different DPI settings or when system DPI scaling changes.
MeasureOverride(SizeF)
Declaration
protected override SizeF MeasureOverride(SizeF availableSize)
Parameters
System.Drawing.SizeF
availableSize
|
Returns
System.Drawing.SizeF
|