# C1.Win.FlexGrid.C1FlexGridBase.AddItem

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_Win_FlexGrid_C1FlexGridBase_AddItem_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.AddItem*">AddItem Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_Win_FlexGrid_C1FlexGridBase_AddItem_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.AddItem*"></a>
<h4 id="C1_Win_FlexGrid_C1FlexGridBase_AddItem_System_String_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.AddItem(System.String)">AddItem(string)</h4>
<div class="markdown level1 summary"><p>Adds a row to the grid and populates the new row with data.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public Row AddItem(string item)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function AddItem(item As String) As Row</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">item</span></td>
      <td><p>String containing the data for the new row. Items are separated by tab characters
by default. You can change the separator character using the <a class="xref" href="C1.Win.FlexGrid.C1FlexGridBase.ClipSeparators.html#C1_Win_FlexGrid_C1FlexGridBase_ClipSeparators">ClipSeparators</a> property.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.Win.FlexGrid.Row.html">Row</a></td>
      <td><p>A reference to the new row.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Win_FlexGrid_C1FlexGridBase_AddItem_System_String__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>You can also add and remove rows using the <a class="xref" href="C1.Win.FlexGrid.C1FlexGridBase.Rows.html#C1_Win_FlexGrid_C1FlexGridBase_Rows">Rows</a> collection. The <a class="xref" href="C1.Win.FlexGrid.C1FlexGridBase.AddItem.html#C1_Win_FlexGrid_C1FlexGridBase_AddItem_System_String_">AddItem(string)</a> 
method provides a concise syntax for creating the row, populating it with data, and then adding it to the grid.</p>
<p>Before using <a class="xref" href="C1.Win.FlexGrid.C1FlexGridBase.AddItem.html#C1_Win_FlexGrid_C1FlexGridBase_AddItem_System_String_">AddItem(string)</a> to add a large number of rows to the grid, remember to set the 
<a class="xref" href="C1.Win.FlexGrid.C1FlexGridBase.Redraw.html#C1_Win_FlexGrid_C1FlexGridBase_Redraw">Redraw</a> property to false. When finished adding the rows, set <a class="xref" href="C1.Win.FlexGrid.C1FlexGridBase.Redraw.html#C1_Win_FlexGrid_C1FlexGridBase_Redraw">Redraw</a> back to 
its original value. This will significantly improve performance.</p>
</div>
<h5 id="C1_Win_FlexGrid_C1FlexGridBase_AddItem_System_String__examples">Examples</h5>
<p>The code below adds 300 rows to the grid.</p>
<pre><code class="lang-csharp">// 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 &lt; 100; i++)
  flex.AddItem("\tcol1\tcol2\tcol3");

// add 100 rows at the top, using pipes as separators
flex.ClipSeparators = "|;";
for (int i = 0; i &lt; 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 &lt; 100; i++)
  flex.AddItem(items, flex.Rows.Count, flex.Cols.Fixed);

// restore painting
flex.Redraw = redraw;</code></pre>



<a id="C1_Win_FlexGrid_C1FlexGridBase_AddItem_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.AddItem*"></a>
<h4 id="C1_Win_FlexGrid_C1FlexGridBase_AddItem_System_Object___" data-uid="C1.Win.FlexGrid.C1FlexGridBase.AddItem(System.Object[])">AddItem(object[])</h4>
<div class="markdown level1 summary"><p>Adds a row to the grid and populates the new row with data.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public Row AddItem(object[] items)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function AddItem(items As Object()) As Row</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a>[]</td>
      <td><span class="parametername">items</span></td>
      <td><p>Array of objects that will be assigned to the new row.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.Win.FlexGrid.Row.html">Row</a></td>
      <td><p>A reference to the new row.</p>
</td>
    </tr>
  </tbody>
</table>


<a id="C1_Win_FlexGrid_C1FlexGridBase_AddItem_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.AddItem*"></a>
<h4 id="C1_Win_FlexGrid_C1FlexGridBase_AddItem_System_String_System_Int32_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.AddItem(System.String,System.Int32)">AddItem(string, int)</h4>
<div class="markdown level1 summary"><p>Adds a row to the grid at a specified position and populates the new row with data.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public Row AddItem(string item, int index)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function AddItem(item As String, index As Integer) As Row</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">item</span></td>
      <td><p>String containing the data for the new row. Items are separated by tab characters
by default. You can change the separator character using the <a class="xref" href="C1.Win.FlexGrid.C1FlexGridBase.ClipSeparators.html#C1_Win_FlexGrid_C1FlexGridBase_ClipSeparators">ClipSeparators</a> property.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">index</span></td>
      <td><p>Position where the new row will be inserted.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.Win.FlexGrid.Row.html">Row</a></td>
      <td><p>A reference to the new row.</p>
</td>
    </tr>
  </tbody>
</table>


<a id="C1_Win_FlexGrid_C1FlexGridBase_AddItem_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.AddItem*"></a>
<h4 id="C1_Win_FlexGrid_C1FlexGridBase_AddItem_System_Object___System_Int32_System_Int32_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.AddItem(System.Object[],System.Int32,System.Int32)">AddItem(object[], int, int)</h4>
<div class="markdown level1 summary"><p>Adds a row to the grid at a specified position and populates the new row with data.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public Row AddItem(object[] items, int rowIndex, int colIndex)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function AddItem(items As Object(), rowIndex As Integer, colIndex As Integer) As Row</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a>[]</td>
      <td><span class="parametername">items</span></td>
      <td><p>Array of objects that will be assigned to the new row.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">rowIndex</span></td>
      <td><p>Position where the new row will be inserted.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">colIndex</span></td>
      <td><p>First column to populate with the items in the <code class="paramref">items</code>
array. This parameter is usually set to the index of the first scrollable column.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.Win.FlexGrid.Row.html">Row</a></td>
      <td><p>A reference to the new row.</p>
</td>
    </tr>
  </tbody>
</table>
</div>
