PivotGridControl.EndUpdate() Method
Unlocks the PivotGridControl object after a call to the BeginUpdate method and causes an immediate visual update.
Namespace: DevExpress.XtraPivotGrid
Assembly: DevExpress.XtraPivotGrid.v24.2.dll
Declaration
Remarks
See PivotGridControl.BeginUpdate to learn more.
Example
The following example demonstrates how to lock the pivot grid, thus preventing it from being redrawn while a sequence of operations that affect its appearance and/or functionality is being performed.In this example, the pivot grid is transposed by moving Row Fields to the Column Area, and vice versa. Prior to this, the BeginUpdate method is called to lock the pivot grid. When the transposition is completed, the pivot grid is unlocked via the EndUpdate method. To ensure that the EndUpdate method is always called even if an exception occurs, calls to the BeginUpdate and EndUpdate methods are wrapped in a try…finally statement.
using System;
using System.Data;
using System.Windows.Forms;
using DevExpress.XtraPivotGrid;
namespace XtraPivotGrid_BeginEndUpdate {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e) {
pivotGridControl1.DataSource = GetDataTable();
}
private void btnBegin_Click(object sender, EventArgs e) {
DateTime startTime = DateTime.Now;
// If an appropriate option is enabled,
// locks the pivot grid to prevent further updates.
if (rbLocked.Checked) pivotGridControl1.BeginUpdate();
try {
// Initiates transposition.
Transpose();
}
finally {
// If the pivot grid has been locked, unlocks it, allowing further updates.
if (rbLocked.Checked) pivotGridControl1.EndUpdate();
}
// Displays the amount of time taken by the transposition.
TimeSpan duration = DateTime.Now - startTime;
MessageBox.Show("Transposition took " +
duration.TotalSeconds.ToString("F2") + " seconds");
}
// Transposes the pivot grid by moving Row Fields to the Column Area, and vice versa.
private void Transpose() {
foreach(PivotGridField field in pivotGridControl1.Fields) {
if (field.Area == PivotArea.RowArea)
field.Area = PivotArea.ColumnArea;
else if (field.Area == PivotArea.ColumnArea)
field.Area = PivotArea.RowArea;
}
}
// Generates pivot grid data.
public static DataTable GetDataTable() {
DataTable table = new DataTable();
table.Columns.Add("A", typeof(string));
table.Columns.Add("B", typeof(string));
table.Columns.Add("Data", typeof(int));
for (int i = 0; i < 1000; i++)
for (int j = 0; j < 500; j++)
table.Rows.Add('A' + i.ToString(), 'B' + j.ToString(), ((int)i / 100));
return table;
}
}
}
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the EndUpdate() method.
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.