Back to Devexpress

TableView.AutoWidth Property

wpf-devexpress-dot-xpf-dot-grid-dot-tableview-58ac4ce6.md

latest6.0 KB
Original Source

TableView.AutoWidth Property

Gets or sets whether column widths are automatically changed so that the total columns’ width matches the grid’s width. This is a dependency property.

Namespace : DevExpress.Xpf.Grid

Assembly : DevExpress.Xpf.Grid.v25.2.dll

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

csharp
public bool AutoWidth { get; set; }
vb
Public Property AutoWidth As Boolean

Property Value

TypeDefaultDescription
Booleanfalse

true, to enable the column auto width feature; otherwise, false.

|

Remarks

Tip

Topics :

Set the AutoWidth property to true to make the GridControl change the column widths automatically. In this case, when an end user changes a column’s width, the GridControl changes the widths of other columns.

xaml
<dxg:GridControl AutoGenerateColumns="AddNew" 
                 EnableSmartColumnsGeneration="True" 
                 ItemsSource="{Binding Customers}">
    <dxg:GridControl.View>
        <dxg:TableView AutoWidth="True"/>
    </dxg:GridControl.View>
</dxg:GridControl>

Use the BaseColumn.ActualWidth property to obtain the column width.

If the automatic column width calculation is disabled, a column’s width is specified by its BaseColumn.Width property. If the total columns’ width exceeds the grid’s width, a horizontal scrollbar is displayed, allowing an end user to scroll grid columns. If you want a column (or columns) to always be displayed onscreen, regardless of scrolling, specify the BaseColumn.Fixed property.

The following code snippets (auto-collected from DevExpress Examples) contain references to the AutoWidth property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-data-grid-display-group-summaries/CS/DisplayGroupSummaries_CodeBehind/MainWindow.xaml#L10

xml
<dxg:GridControl.View>
    <dxg:TableView AutoWidth="True"/>
</dxg:GridControl.View>

wpf-data-grid-implement-custom-grouping/CS/CustomGrouping_CodeBehind/MainWindow.xaml#L22

xml
<dxg:GridControl.View>
    <dxg:TableView AutoWidth="True" ShowGroupedColumns="True"/>
</dxg:GridControl.View>

wpf-data-grid-implement-custom-filtering/CS/CustomFiltering_MVVM/MainWindow.xaml#L29

xml
<dxg:GridControl.View>
    <dxg:TableView AutoWidth="True"
                   ShowGroupPanel="False"

wpf-data-grid-summarize-empty-cells/CS/CustomSummary_EmptyCells_CodeBehind/MainWindow.xaml#L17

xml
<dxg:TableView x:Name="view"
               AutoWidth="True"
               NavigationStyle="Cell"

wpf-data-grid-display-detail-content-in-tabs/CS/WpfApplication18/MainWindow.xaml#L14

xml
<dxg:GridControl.View>
    <dxg:TableView DetailHeaderContent="Employees" AutoWidth="True" ShowGroupPanel="False"/>
</dxg:GridControl.View>

wpf-data-grid-create-master-detail-grid-in-code/CS/MasterDetailInCode/MainWindow.xaml.cs#L19

csharp
gridControl.View = new TableView();
((TableView)gridControl.View).AutoWidth = true;
((TableView)gridControl.View).ShowGroupPanel = false;

wpf-data-grid-create-master-detail-grid-in-code/VB/MasterDetailInCode/MainWindow.xaml.vb#L22

vb
gridControl.View = New TableView()
CType(gridControl.View, TableView).AutoWidth = True
CType(gridControl.View, TableView).ShowGroupPanel = False

See Also

TableView Class

TableView Members

DevExpress.Xpf.Grid Namespace