Back to Devexpress

PivotGridControl.ExpandAllColumnsAsync() Method

windowsforms-devexpress-dot-xtrapivotgrid-dot-pivotgridcontrol-7fd5f90e.md

latest6.4 KB
Original Source

PivotGridControl.ExpandAllColumnsAsync() Method

Expands all columns asynchronously.

Namespace : DevExpress.XtraPivotGrid

Assembly : DevExpress.XtraPivotGrid.v25.2.dll

NuGet Package : DevExpress.Win.PivotGrid

Declaration

csharp
public Task<bool> ExpandAllColumnsAsync()
vb
Public Function ExpandAllColumnsAsync As Task(Of Boolean)

Returns

TypeDescription
Task<Boolean>

An asynchronous operation that returns true in case of success.

|

Remarks

The ExpandAllColumnsAsync method is asynchronous. ExpandAllColumnsAsync starts to execute the related operation in a background thread, and returns the Pivot Grid control. The main UI thread remains unblocked to allow the application to continue responding to user actions. Refer to the following topic for more information: Asynchronous Mode.

Use the following methods to collapse or expand Pivot Grid columns:

CollapseAllColumnsAsyncCollapses all columns asynchronously.ExpandAllColumnsExpands all columns.CollapseAllColumnsCollapses all columns.

Use the following methods to collapse or expand Pivot Grid rows:

ExpandAllRowsAsyncExpands all rows asynchronously.CollapseAllRowsAsyncCollapses all rows asynchronously.ExpandAllRows()Expands all rows.CollapseAllRowsCollapses all rows.

You can specify whether a user can expand or collapse field values in the UI. For this, use the PivotGridFieldOptions.AllowExpand property.

Example

The following example shows how to expand all columns in the Pivot Grid asynchronously. The image below displays the resulting Pivot Grid with expanded columns for the Country and City fields.

csharp
using DevExpress.XtraPivotGrid;
using System.Windows.Forms;

namespace WindowsFormsApp2 {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
            pivotGridControl1.OptionsBehavior.UseAsyncMode = true;
            ConfigureLayout();
        }
        async void ConfigureLayout() {
            pivotGridControl1.BeginUpdate();
            // Create and configure Pivot Grid fields
            PivotGridField fieldCountry = pivotGridControl1.Fields.Add("Country", PivotArea.ColumnArea);
            fieldCountry.DataBinding = new DataSourceColumnBinding("[Customer].[Country].[Country]");
            fieldCountry.Name = "fieldCountry";

            PivotGridField fieldCity = pivotGridControl1.Fields.Add("City", PivotArea.ColumnArea);
            fieldCity.DataBinding = new DataSourceColumnBinding("[Customer].[City].[City]");
            fieldCity.Name = "fieldCity";
            // ...
            await pivotGridControl1.EndUpdateAsync();

            await pivotGridControl1.ExpandAllColumnsAsync();
        }
    }
}
vb
Imports DevExpress.XtraPivotGrid
Imports System.Windows.Forms

Namespace WindowsFormsApp2
    Partial Public Class Form1
        Inherits Form

        Public Sub New()
            InitializeComponent()
            pivotGridControl1.OptionsBehavior.UseAsyncMode = True
            ConfigureLayout()
        End Sub
        Private Async Sub ConfigureLayout()
            pivotGridControl1.BeginUpdate()
            ' Create and configure Pivot Grid fields
            Dim fieldCountry As PivotGridField = pivotGridControl1.Fields.Add("Country", PivotArea.ColumnArea)
            fieldCountry.DataBinding = New DataSourceColumnBinding("[Customer].[Country].[Country]")
            fieldCountry.Name = "fieldCountry"

            Dim fieldCity As PivotGridField = pivotGridControl1.Fields.Add("City", PivotArea.ColumnArea)
            fieldCity.DataBinding = New DataSourceColumnBinding("[Customer].[City].[City]")
            fieldCity.Name = "fieldCity"
            ' ...
            Await pivotGridControl1.EndUpdateAsync()

            Await pivotGridControl1.ExpandAllColumnsAsync()
        End Sub
    End Class
End Namespace

See Also

ExpandAllColumns()

CollapseAllColumnsAsync

CollapseAllColumns()

CollapseAllRowsAsync

CollapseAllRows()

ExpandAllRowsAsync

ExpandAllRows()

PivotGridControl Class

PivotGridControl Members

DevExpress.XtraPivotGrid Namespace