GridLayout
A layout panel that arranges child elements in a sophisticated grid structure with configurable rows, columns, spanning, and advanced sizing modes.
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.
Definition
Namespace:Telerik.WinControls.Layouts
Assembly:Telerik.WinControls.dll
Syntax:
public class GridLayout : LayoutPanel, IDisposable, INotifyPropertyChanged, ICustomTypeDescriptor, ISupportSystemSkin, IStylableNode
Inheritance: objectDisposableObjectRadObjectRadElementLayoutPanelGridLayout...
Implements:
Inherited Members
Constructors
Initializes a new instance of the GridLayout class with a single cell (1x1 grid).
Initializes a new instance of the GridLayout class with the specified number of columns and rows.
public GridLayout(int columnsCount, int rowsCount)
The number of columns to create in the grid. Must be greater than 0.
rowsCountintThe number of rows to create in the grid. Must be greater than 0.
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
public static readonly RadProperty CellPaddingProperty
public static readonly RadProperty ColSpanProperty
public static readonly RadProperty ColumnIndexProperty
public static readonly RadProperty RowIndexProperty
public static readonly RadProperty RowSpanProperty
Properties
Columns
List<GridLayoutColumn>
Gets or sets the collection of column definitions that determine the width and sizing behavior of grid columns.
public List<GridLayoutColumn> Columns { get; set; }
A List<T> of GridLayoutColumn objects that define the grid's column structure.
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
List<GridLayoutRow>
Gets or sets the collection of row definitions that determine the height and sizing behavior of grid rows.
public List<GridLayoutRow> Rows { get; set; }
A List<T> of GridLayoutRow objects that define the grid's row structure.
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
Arranges the RadElement to its final location. The element must call the Arrange method of each of its children.
protected override SizeF ArrangeOverride(SizeF finalSize)
The size that is available for element.
Returns:The rectangle occupied by the element. Usually finalSize. Should you return different size, the Layout system will restart measuring and rearranging the items. That could lead to infinite recursion.
Overrides:
In this method call to the Arrange method of each child must be made.
Handles DPI scaling changes by invalidating layout measurements and updating the grid structure.
public override void DpiScaleChanged(SizeF scaleFactor)
The scaling factor applied due to DPI changes.
Overrides:
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.
Measures the space required by the RadElement
Used by the layout system.
protected override SizeF MeasureOverride(SizeF availableSize)
The size that is available to the RadElement. The available size can be infinity (to take the full size of the element)
Returns:The minimum size required by the element to be completely visible. Cannot be infinity.
Overrides:
In this method call to the Measure method of each child must be made.