Back to Devexpress

AdvancedColumnLayout.ColumnDefinitions Property

mobilecontrols-devexpress-dot-xamarinforms-dot-datagrid-dot-advancedcolumnlayout.md

latest4.0 KB
Original Source

AdvancedColumnLayout.ColumnDefinitions Property

Provides access to a collection of objects that control the width of each column within the grid’s multi-row layout.

Namespace : DevExpress.XamarinForms.DataGrid

Assembly : DevExpress.XamarinForms.Grid.dll

NuGet Package : DevExpress.XamarinForms.Grid

Declaration

csharp
[XtraSerializableProperty(XtraSerializationVisibility.SimpleCollection, true, false, true)]
public ObservableCollection<ColumnDefinition> ColumnDefinitions { get; }

Property Value

TypeDescription
ObservableCollection<Xamarin.Forms.ColumnDefinition>

A collection of objects that define the width of columns within the grid’s multi-row layout.

|

Example

This example shows how to define the multi-row column layout for a grid that contains information about employees.

  1. Enable advanced layout mode and specify layout details - the number of columns and rows, and each column width and row height. To do this, set the DataGridView.AdvancedColumnLayout property to the AdvancedColumnLayout object with the specified ColumnDefinitions and RowDefinitions collections.

  2. Arrange columns within the specified layout. To do this, specify the following properties for each column object:

Note

The specified column layout is also applied to column headers and data summaries.

View Example

xaml
<dxg:DataGridView ItemsSource="{Binding Path=Employees}">
    <dxg:DataGridView.AdvancedColumnLayout>
        <dxg:AdvancedColumnLayout>
            <dxg:AdvancedColumnLayout.ColumnDefinitions>
                <ColumnDefinition Width="100"/>
                <ColumnDefinition Width="6*"/>
                <ColumnDefinition Width="7*"/>
                <ColumnDefinition Width="6*"/>
                <ColumnDefinition Width="9*"/>
            </dxg:AdvancedColumnLayout.ColumnDefinitions>
            <dxg:AdvancedColumnLayout.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </dxg:AdvancedColumnLayout.RowDefinitions>
        </dxg:AdvancedColumnLayout>
    </dxg:DataGridView.AdvancedColumnLayout>

    <dxg:ImageColumn FieldName="Image" Caption="Photo" RowSpan="3"/>

    <dxg:TextColumn FieldName="FullName" Column="1" ColumnSpan="2"/>
    <dxg:TextColumn FieldName="Phone" Column="3" ColumnSpan="2"/>

    <dxg:TextColumn FieldName="JobTitle" Row="1" Column="1" ColumnSpan="4"/>

    <dxg:DateColumn FieldName="BirthDate" Row="2" Column="1" ColumnSpan="2"/>
    <dxg:DateColumn FieldName="HireDate" Row="2" Column="3" ColumnSpan="2"/>

    <dxg:TextColumn FieldName="AddressLine1" Caption="Address" Row="3" ColumnSpan="2"/>
    <dxg:TextColumn FieldName="City" Row="3" Column="2"/>
    <dxg:TextColumn FieldName="PostalCode" Caption="Code" Row="3" Column="3"/>
    <dxg:TextColumn FieldName="CountryRegionName" Caption="Country" Row="3" Column="4"/>
</dxg:DataGridView>

See Also

AdvancedColumnLayout Class

AdvancedColumnLayout Members

DevExpress.XamarinForms.DataGrid Namespace