ClassGridLayout
A layout panel that arranges child elements in a sophisticated grid structure with configurable rows, columns, spanning, and advanced sizing modes.
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
GridLayout()
Initializes a new instance of the GridLayout class with a single cell (1x1 grid).
Declaration
public GridLayout()
Remarks
This constructor creates a minimal grid layout with one column and one row, both configured with default sizing behavior. This is ideal for simple layouts that may be expanded later by adding additional rows and columns to the Columns and Rows collections.
GridLayout(int, int)
Initializes a new instance of the GridLayout class with the specified number of columns and rows.
Declaration
public GridLayout(int columnsCount, int rowsCount)
Parameters
columnsCount
The number of columns to create in the grid. Must be greater than 0.
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
Declaration
public static readonly RadProperty CellPaddingProperty
Field Value
ColSpanProperty
Declaration
public static readonly RadProperty ColSpanProperty
Field Value
ColumnIndexProperty
Declaration
public static readonly RadProperty ColumnIndexProperty
Field Value
RowIndexProperty
Declaration
public static readonly RadProperty RowIndexProperty
Field Value
RowSpanProperty
Declaration
public static readonly RadProperty RowSpanProperty
Field Value
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
List<GridLayoutColumn>
A 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
List<GridLayoutRow>
A 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)
Arranges the RadElement to its final location. The element must call the Arrange method of each of its children.
Declaration
protected override SizeF ArrangeOverride(SizeF finalSize)
Parameters
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
Remarks
In this method call to the Arrange method of each child must be made.
DpiScaleChanged(SizeF)
Handles DPI scaling changes by invalidating layout measurements and updating the grid structure.
Declaration
public override void DpiScaleChanged(SizeF scaleFactor)
Parameters
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)
Measures the space required by the RadElement
Used by the layout system.
Declaration
protected override SizeF MeasureOverride(SizeF availableSize)
Parameters
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
Remarks
In this method call to the Measure method of each child must be made.