Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Collapse]Editors and Simple Controls
   [Collapse]Simple Editors
    [Expand]Included Components
    [Expand]Editors Structure
    [Collapse]Editors Features
      Text Editing Overview
     [Expand]Mask Editors Overview
     [Expand]Formatting and Parsing Values
     [Expand]Editor Buttons Overview
     [Expand]Dropdown Editors Overview
      Image Editing Menu
     [Expand]Data Binding Overview
     [Expand]Appearance Customization
     [Collapse]Miscellaneous Features
       Batch Modifications
       Validation
    [Expand]Member Tables
    [Expand]Examples
   [Expand]Lookup Editors
   [Expand]Token Edit Control
   [Expand]Breadcrumb Edit Control
   [Expand]Range Control
   [Expand]Image Slider
    Camera Control
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Batch Modifications

The XtraEditors library supports batch modifications. You can perform a sequence of modifications affecting the editor's appearance, and only update an editor, giving you a significant performance increase. This topic explains the batch modifications concept and provides examples demonstrating the technique.

Expanded The Batch Modifications Concept

Normally, each operation affecting the editor's appearance forces the editor to recalculate its view information and repaint itself. As stated above, you may need to avoid this when performing several changes. To do this, the code performing the changes must be enclosed within the RepositoryItem.BeginUpdate/RepositoryItem.EndUpdate or RepositoryItem.BeginUpdate/RepositoryItem.CancelUpdate method calls. The RepositoryItem.BeginUpdate method increments an internal counter, initially zero) by one. The RepositoryItem.EndUpdate and RepositoryItem.CancelUpdate methods decrement this counter. The editor's view information recalculation and repainting is only performed when the counter value is zero.So, the code enclosed into the method pairs above does not force editor updates after each operation.

Since the RepositoryItem.BeginUpdate, RepositoryItem.EndUpdate and RepositoryItem.CancelUpdate methods use a counter, nesting the calls to these methods is allowed. However, there must be the same number of RepositoryItem.BeginUpdate and RepositoryItem.EndUpdate/RepositoryItem.CancelUpdate method calls. If the number of method calls that end batch modification is less than RepositoryItem.BeginUpdate method calls, the editor will not update itself further.

It is a common technique to use the try...finally block to ensure that a RepositoryItem.EndUpdate/RepositoryItem.CancelUpdate method call is actually performed to avoid locking the editor .

Expanded Comparing the EndUpdate and CancelUpdate Methods

If the RepositoryItem.EndUpdate method is called to unlock an editor, the editor is updated immediately. Its view information is recalculated and it is repainted to reflect the changes made. On the other hand, the RepositoryItem.CancelUpdate method does not force an immediate update. Use this method only if you are sure that the editor's appearance remains the same after all the changes have been applied. This enables you to avoid an unnecessary update.

The sample code below shows an example of using the RepositoryItem.BeginUpdate and RepositoryItem.EndUpdate methods. These methods prevent a ButtonEdit from being updated while changing the position of its buttons.

The following image shows the editor's appearance before and after the sample code's execution.

How would you rate this topic?​​​​​​​