Locks the TreeList, preventing visual updates of the object and its elements until the EndUpdate or CancelUpdate method is called.
Once the BeginUpdate method has been called, modifying the TreeList and its elements does not result in immediate visual updates. So, multiple modifications can be made to the TreeList object and its elements without a major impact on performance or screen flickering. After all the desired operations have been finished, call the EndUpdate or CancelUpdate method. Use the EndUpdate method to immediately perform a visual update, reflecting all the changes made. If no immediate visual update is required (for example, if no visual setting has been affected by the operations performed), call the CancelUpdate method.
The BeginUpdate, EndUpdate and CancelUpdate methods use an internal counter to implement the update functionality. The counter's initial value is 0. The BeginUpdate method increments the counter. The EndUpdate and CancelUpdate decrement the counter.
The object's visual updates (change notifications) are forbidden if the counter's value is greater than 0, and the updates are enabled if the counter's value is 0.
Each call to BeginUpdate must be paired with a call to EndUpdate or CancelUpdate. To ensure that EndUpdate/CancelUpdate is always called even if an exception occurs, use the try...finally statement.
Here is an example of using the BeginUpdate and EndUpdate methods. For instance, you may want to hide preview sections and row footers. If the code performing these changes is not enclosed within the BeginUpdate and EndUpdate method calls, the control will be repainted twice. Otherwise, only a single repainting will be performed.
The BeginUpdate and EndUpdate methods do not prevent the Tree List control's excessive internal updates when data is sorted, when nodes are added, deleted or modified or when the control's underlying data source is modified. To prevent excessive updates when changing specific options affecting the order of nodes, use the TreeList.BeginSort and TreeList.EndSort methods. To prevent excessive updates when the node structure is changed in bound mode, use the TreeList.LockReloadNodes and TreeList.UnlockReloadNodes methods, and in unbound mode, use the TreeList.BeginUnboundLoad and TreeList.EndUnboundLoad methods.