Syntax
Success = LayoutGridSetColumn(Layout, Index=#Null, Size.d=#PG_Grid_Default, isPercent.b=#False)Description
Sets the template size for a specific column in a Grid layout. This defines the ideal width of the column.
Parameters
Layout
The handle of the Grid layout object. If #Null, it targets
the current layout.
Index (optional)
The 1-based index of the column to modify. If #Null or 0,
it appends a new column definition.
Size.d (optional)
The desired size for the column. Can be:
- A specific value (DIPs).
#PG_Grid_Auto: Size is determined by any remaining available space evenly distributed amongst auto columns.#PG_Grid_MaxContent: Size is determined by the largest intrinsic max-content size of items in the column.#PG_Grid_Default: Uses the layout's default column size (LayoutGridSetColumnDefault()).
isPercent.b (optional)
If #True and Size is a numeric value, the size
is treated as a percentage of the layout container's width. Default is
#False.
Return Value
Returns #True if the column size was successfully set,
or #False if the layout handle or parameters were
invalid.
Remarks
This property only applies to layouts whose type is
#PG_Layout_Type_Grid. It defines the explicit grid
structure. Columns beyond the defined template count will typically use
the default column size settings. You can also set minimum and maximum
constraints using LayoutGridSetColumnMin() and LayoutGridSetColumnMax().
Example
IncludeFile "ProGUI_PB.pbi"
StartProGUI()
MyWindow = CreateWindow(0, 0, 500, 300, "Grid Columns", #PG_Window_Default | #PG_Window_LayoutGrid) ; Create with a grid layout
If MyWindow
LayoutSetPadding(#Null, 10) ; Set the current layout padding
LayoutGridSetGapSize(#Null, 10) ; Add gaps
; Define columns
LayoutGridSetColumn(#Null, 1, 100) ; Column 1: Fixed 100 DIPs
LayoutGridSetColumn(#Null, 2, #PG_Grid_Auto) ; Column 2: Auto size based on content
LayoutGridSetColumn(#Null, 3, 50, #True) ; Column 3: 50% of container width
; Add widgets to the grid
Widget1 = CreateWidget(0, 0, 0, 50)
Widget2 = CreateWidget(0, 0, 0, 50) ; Affects column 2 size
Widget3 = CreateWidget(0, 0, 0, 50)
WindowShow(MyWindow, #True, #PG_WindowShow_ScreenCentered)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
StopProGUI()See Also
LayoutSetType, LayoutGridGetColumn, LayoutGridSetColumnMin, LayoutGridSetColumnMax, LayoutGridSetColumnDefault, LayoutGridSetRow, WidgetSetColumnStart, WidgetSetColumnSpan
Supported OS
Windows, Linux