FlexGrid for WinForms
BeginUpdate Method (C1FlexGridBase)
Example 



Maintains performance by preventing the control from updating itself until the C1.Win.C1FlexGrid.Util.BaseControls.ScrollableControl.EndUpdate method is called.
Syntax
'Declaration
 
Public Overrides Sub BeginUpdate() 
'Usage
 
Dim instance As C1FlexGridBase
 
instance.BeginUpdate()
public override void BeginUpdate()
public:
void BeginUpdate(); override 
Remarks
The BeginUpdate and EndUpdate methods are used to optimize the performance of the grid. Call BeginUpdate before making extensive changes, and call EndUpdate when done to suspend repainting. This will reduce flicker and increase performance. This optimization is especially effective when adding large numbers of rows to the grid, because it needs to recalculate ranges and update scrollbars each time a row is added.
Example
The code below shows how to add a large number of rows to the grid efficiently. Note how the EndUpdate method is called inside a 'finally' block to ensure repainting is properly restored.
void UpdateGrid(C1FlexGrid flex)
{
  try
  {
    flex.BeginUpdate(); // suspend painting to avoid flicker
    flex.Rows.Count = 1;
    for (int i = 1; i < 10000; i++)
      flex.AddItem("Row " + i.ToString());
  }
  finally
  {
    flex.EndUpdate(); // always restore painting
  }
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

C1FlexGridBase Class
C1FlexGridBase Members

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Send Feedback