SpreadsheetControl.EndUpdate() Method

Unlocks the SpreadsheetControl object after a call to the SpreadsheetControl.BeginUpdate method and causes an immediate visual update.

Namespace: DevExpress.XtraSpreadsheet

Assembly: DevExpress.XtraSpreadsheet.v20.1.dll

Declaration

public void EndUpdate()
Public Sub

Remarks

Enclose your code in the SpreadsheetControl.BeginUpdate - EndUpdate method calls to suppress the SpreadsheetControl's visual updates and improve its performance when you perform multiple changes to a spreadsheet document.

Each call to SpreadsheetControl.BeginUpdate must be paired with the EndUpdate call. The SpreadsheetControl.BeginUpdate method locks the SpreadsheetControl, so that it is not rendered after each modification. The EndUpdate method unlocks the control to enable all the changes to take effect. You can use the try...finally statement to ensure that EndUpdate is always called even if an exception occurs.

The following example shows how to use the SpreadsheetControl.BeginUpdate - EndUpdate methods.


spreadsheetControl1.BeginUpdate();
try
{
    Worksheet worksheet = spreadsheetControl1.Document.Worksheets[0];
    spreadsheetControl1.Unit = DevExpress.Office.DocumentUnit.Point;

    // Create a multiplication table.
    worksheet.Cells["A1"].Value = "*";
    for(int i = 1; i < 11; i++)
    {
        // Create a header column.
        worksheet.Columns["A"][i].Value = i;
        // Create a header row.
        worksheet.Rows["1"][i].Value = i;
    }

    // Multiply values of header cells.
    worksheet.Range["B2:K11"].Formula = "=B$1*$A2";

    // Obtain the data range.
    CellRange tableRange = worksheet.GetDataRange();

    // Specify the row height and column width.
    tableRange.RowHeight = 40;
    tableRange.ColumnWidth = 40;

    // Align the table content.
    tableRange.Alignment.Horizontal = SpreadsheetHorizontalAlignment.Center;
    tableRange.Alignment.Vertical = SpreadsheetVerticalAlignment.Center;

    // Fill the header cells.
    CellRange headerCells = worksheet.Range.Union(worksheet.Range["A1:K1"], worksheet.Range["A2:A11"]);
    headerCells.FillColor = Color.FromArgb(0xf7, 0x9b, 0x77);
    headerCells.Font.Bold = true;

    // Fill cells that contain multiplication results.
    worksheet.Range["B2:K11"].FillColor = Color.FromArgb(0xfe, 0xf2, 0xe4);
}
finally
{
    spreadsheetControl1.EndUpdate();
}

Implements

DevExpress.Utils.IBatchUpdateable.EndUpdate()
See Also