Back to Devexpress

GridControl.BeginUpdate() Method

windowsforms-devexpress-dot-xtragrid-dot-gridcontrol-d95bef50.md

latest5.9 KB
Original Source

GridControl.BeginUpdate() Method

Locks the GridControl object by preventing visual updates of the object and its elements until the EndUpdate method is called.

Namespace : DevExpress.XtraGrid

Assembly : DevExpress.XtraGrid.v25.2.dll

NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

csharp
public virtual void BeginUpdate()
vb
Public Overridable Sub BeginUpdate

Remarks

You can use the BeginUpdate and GridControl.EndUpdate methods to prevent excessive visual updates to the currently visible Views. After the BeginUpdate method call, the currently opened Views are locked, and do not reflect any appearance changes. The GridControl.EndUpdate method unlocks and redraws the Views.

To prevent excessive updates in a single View, use the BaseView.BeginUpdate and BaseView.EndUpdate methods.

The BeginUpdate and EndUpdate methods do not prevent grid updates caused by data-aware operations (for instance, adding and deleting records, sorting and grouping data). To prevent the grid from being updated in these instances, call the BaseView.BeginDataUpdate and BaseView.EndDataUpdate methods.

Note

Do not change the GridControl.MainView property between the GridControl.BeginUpdate and GridControl.EndUpdate method calls. Instead, set the GridControl.MainView property outside the BeginUpdate / EndUpdate block.

Refer to the Batch Modifications Overview topic, for information on batch modifications.

The code sample below illustrates how to pause visual updates in a grid.

csharp
gridControl1.BeginUpdate(); // Pause visual updates
foreach (GridColumn column in gridView1.Columns)
{
    if (column.FieldName.Substring(0, 8) == "colPrice")
        column.AppearanceCell.BackColor = Color.Aqua;
}
gridControl1.EndUpdate(); // Unpause visual updates
vb
gridControl1.BeginUpdate() ' Pause visual updates
For Each column As GridColumn In gridView1.Columns
    If column.FieldName.Substring(0, 8) = "colPrice" Then
        column.AppearanceCell.BackColor = Color.Aqua
    End If
Next column
gridControl1.EndUpdate() ' Unpause visual updates

The following code snippets (auto-collected from DevExpress Examples) contain references to the BeginUpdate() 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.

XDL_how-to-convert-the-criteriaoperator-to-a-lambda-expression-to-use-it-for-iqueryable-e2596/CS/WindowsFormsApplication152/Form1.cs#L57

csharp
{
    gridControl1.BeginUpdate();
    try

winforms-grid-use-layoutview-as-master-view/CS/WindowsApplication3/MasterDetailHelper.cs#L115

csharp
void OnPopup(object sender, EventArgs e) {
    DetailGrid.BeginUpdate();
    try {

XDL_how-to-convert-the-criteriaoperator-to-a-lambda-expression-to-use-it-for-iqueryable-e2596/VB/WindowsFormsApplication152/Form1.vb#L42

vb
Private Sub OnUpdateFilter(ByVal sender As Object, ByVal e As EventArgs)
    gridControl1.BeginUpdate()
    Try

winforms-grid-use-layoutview-as-master-view/VB/WindowsApplication3/MasterDetailHelper.vb#L126

vb
Private Sub OnPopup(ByVal sender As Object, ByVal e As EventArgs)
    DetailGrid.BeginUpdate()
    Try

See Also

GridControl.EndUpdate

BeginUpdate()

BaseView.EndUpdate

Batch Modifications

GridControl Class

GridControl Members

DevExpress.XtraGrid Namespace