Back to Devexpress

GanttControl.CancelUpdate() Method

windowsforms-devexpress-dot-xtragantt-dot-ganttcontrol-e773cd80.md

latest3.0 KB
Original Source

GanttControl.CancelUpdate() Method

Allows the framework to redraw the control after the BeginUpdate method is called. Does not redraw the control immediately.

Namespace : DevExpress.XtraGantt

Assembly : DevExpress.XtraGantt.v25.2.dll

NuGet Package : DevExpress.Win.Gantt

Declaration

csharp
public override void CancelUpdate()
vb
Public Overrides Sub CancelUpdate

Remarks

After BeginUpdate is called, the framework cannot redraw the control on-screen. You can call this method before you make multiple changes at a time (add multiple items to a collection, customize multiple appearance settings, etc.). This prevents the control from being redrawn after each change and improves performance.

When changes are made, call the CancelUpdate or EndUpdate method. These methods allow the framework to redraw the control. The EndUpdate method also forces the framework to redraw the control immediately. To ensure that the CancelUpdate or EndUpdate method is called even if an exception is thrown, use the try…finally statement.

The BeginUpdate method also disables automatic scheduling — dependent tasks are not re-scheduled when a task is changed (see ScheduleMode).

Example

The code below defers all project tasks for one month.

csharp
using DevExpress.XtraTreeList.Nodes;
using DevExpress.XtraTreeList.Nodes.Operations;

ganttControl1.BeginUpdate();
try {
    ganttControl1.NodesIterator.DoOperation(new MyOperation());
}
finally {
    ganttControl1.EndUpdate();
}

public class MyOperation : TreeListOperation {
    public override void Execute(TreeListNode node) {
        node.SetValue("StartDate", ((DateTime)node.GetValue("StartDate")).AddMonths(1));
    }
}
vb
Imports DevExpress.XtraTreeList.Nodes
Imports DevExpress.XtraTreeList.Nodes.Operations

ganttControl1.BeginUpdate()
Try
    ganttControl1.NodesIterator.DoOperation(New MyOperation())
Finally
    ganttControl1.EndUpdate()
End Try

Public Class MyOperation
    Inherits TreeListOperation

    Public Overrides Sub Execute(ByVal node As TreeListNode)
        node.SetValue("StartDate", DirectCast(node.GetValue("StartDate"), DateTime).AddMonths(1))
    End Sub
End Class

See Also

BeginUpdate()

EndUpdate()

GanttControl Class

GanttControl Members

DevExpress.XtraGantt Namespace