windowsforms-devexpress-dot-xtragantt-dot-ganttcontrol-2de22fde.md
Does not allow the framework to redraw the control until the CancelUpdate or EndUpdate method is called.
Namespace : DevExpress.XtraGantt
Assembly : DevExpress.XtraGantt.v25.2.dll
NuGet Package : DevExpress.Win.Gantt
public override void BeginUpdate()
Public Overrides Sub BeginUpdate
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).
The code below defers all project tasks for one month.
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));
}
}
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
The following code snippet (auto-collected from DevExpress Examples) contains a reference 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.
xaf-win-gantt-control/CS/XPO/GanttSolutionXPO/GanttSolutionXPO.Win/Editors/CustomGanttEditor.cs#L39
try {
control.BeginUpdate();
control.DataSource = controlDataSource;
See Also