Xceed Grid for WinForms provides support for transactional operations during batch modifications (to the grid or its elements) through its implementation of the ISupportInitialize interface. During transactional operations, data will not be loaded into the grid, sorting operations will not be done and the visible positions of columns will not be resequenced.
Batch modifications begin with a call to the grid's BeginInit method and end with a call to the EndInit method. When EndInit is called, the data will be loaded into the grid (if any data binding occurred during the process), data rows will be sorted (if a sort operation was requested) and the visible positions of columns will be resequenced (if the VisibleIndex properties of columns were modified).
For example, let's assume that the following columns start in the following visible positions.
See example
VB.NET |
Copy Code |
---|---|
grid.Columns( 0 ).VisibleIndex = 0 grid.Columns( 1 ).VisibleIndex = 1 grid.Columns( 2 ).VisibleIndex = 2 grid.Columns( 3 ).VisibleIndex = 3 |
C# |
Copy Code |
---|---|
grid.Columns[ 0 ].VisibleIndex = 0; grid.Columns[ 1 ].VisibleIndex = 1; grid.Columns[ 2 ].VisibleIndex = 2; grid.Columns[ 3 ].VisibleIndex = 3; |
See example
VB.NET |
Copy Code |
---|---|
grid.BeginInit() grid.Columns( 0 ).VisibleIndex = 2 grid.Columns( 1 ).VisibleIndex = 3 grid.EndInit() |
C# |
Copy Code |
---|---|
grid.BeginInit(); grid.Columns[ 0 ].VisibleIndex = 2; grid.Columns[ 1 ].VisibleIndex = 3; grid.EndInit(); |
See example
VB.NET |
Copy Code |
---|---|
grid.Columns( 0 ).VisibleIndex = 0 grid.Columns( 1 ).VisibleIndex = 2 grid.Columns( 2 ).VisibleIndex = 1 grid.Columns( 3 ).VisibleIndex = 3 |
C# |
Copy Code |
---|---|
grid.Columns[ 0 ].VisibleIndex = 0; grid.Columns[ 1 ].VisibleIndex = 2; grid.Columns[ 2 ].VisibleIndex = 1; grid.Columns[ 3 ].VisibleIndex = 3; |
If the visible positions of the columns would have been changed outside of calls to BeginInit and EndInit, the result would have been:
See example
VB.NET |
Copy Code |
---|---|
grid.Columns( 0 ).VisibleIndex = 1 grid.Columns( 1 ).VisibleIndex = 3 grid.Columns( 2 ).VisibleIndex = 0 grid.Columns( 3 ).VisibleIndex = 2 |
C# |
Copy Code |
---|---|
grid.Columns[ 0 ].VisibleIndex = 1; grid.Columns[ 1 ].VisibleIndex = 3; grid.Columns[ 2 ].VisibleIndex = 0; grid.Columns[ 3 ].VisibleIndex = 2; |
Although the column definitions are read during calls to BeginInit and EndInit, the data rows are not loaded into the grid until EndInit is called. If the grid's data binding is reset during calls to BeginInit and EndInit, all the data rows currently in the grid will be cleared however, the grid will not be populated with the new data rows until EndInit is called.