FlexGrid for WinForms
AddItem(String) Method
Example 



String containing the data for the new row. Items are separated by tab characters by default. You can change the separator character using the ClipSeparators property.
Adds a row to the grid and populates the new row with data.
Syntax
'Declaration
 
Public Overloads Function AddItem( _
   ByVal item As String _
) As Row
'Usage
 
Dim instance As C1FlexGridBase
Dim item As String
Dim value As Row
 
value = instance.AddItem(item)
public Row AddItem( 
   string item
)
public:
Row^ AddItem( 
   String^ item
) 

Parameters

item
String containing the data for the new row. Items are separated by tab characters by default. You can change the separator character using the ClipSeparators property.

Return Value

A reference to the new row.
Remarks

You can also add and remove rows using the Rows collection. The AddItem(String) method provides a concise syntax for creating the row, populating it with data, and then adding it to the grid.

Before using AddItem(String) to add a large number of rows to the grid, remember to set the Redraw property to false. When finished adding the rows, set Redraw back to its original value. This will significantly improve performance.

Example
The code below adds 300 rows to the grid.
// suspend painting to improve performance
bool redraw = flex.Redraw;
flex.Redraw = false;
            
// append 100 rows, using tabs as separators
flex.ClipSeparators = "\t\n";
for (int i = 0; i < 100; i++)
  flex.AddItem("\tcol1\tcol2\tcol3");
  
// add 100 rows at the top, using pipes as separators
flex.ClipSeparators = "|;";
for (int i = 0; i < 100; i++)
  flex.AddItem("|col1|col2|col3", 0);
  
// append 100 rows at the bottom, using an object array
object[] items = { "col1", "col2", "col3" };
for (int i = 0; i < 100; i++)
  flex.AddItem(items, flex.Rows.Count, flex.Cols.Fixed);
  
// restore painting
flex.Redraw = redraw;
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
Overload List

 

 


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

Send Feedback