# C1.Win.FlexGrid.C1FlexGridBase.AutoSizeCols

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_Win_FlexGrid_C1FlexGridBase_AutoSizeCols_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.AutoSizeCols*">AutoSizeCols Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_Win_FlexGrid_C1FlexGridBase_AutoSizeCols_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.AutoSizeCols*"></a>
<h4 id="C1_Win_FlexGrid_C1FlexGridBase_AutoSizeCols_System_Int32_System_Int32_System_Int32_System_Int32_System_Int32_C1_Win_FlexGrid_AutoSizeFlags_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.AutoSizeCols(System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,C1.Win.FlexGrid.AutoSizeFlags)">AutoSizeCols(int, int, int, int, int, AutoSizeFlags)</h4>
<div class="markdown level1 summary"><p>Adjusts the width of a column range to fit the data in a cell range.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public virtual void AutoSizeCols(int topRow, int leftCol, int bottomRow, int rightCol, int extraSpace, AutoSizeFlags flags)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Overridable Sub AutoSizeCols(topRow As Integer, leftCol As Integer, bottomRow As Integer, rightCol As Integer, extraSpace As Integer, flags As AutoSizeFlags)</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.int32">int</a></td>
      <td><span class="parametername">topRow</span></td>
      <td><p>Top row in the range.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">leftCol</span></td>
      <td><p>Left column in the range.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">bottomRow</span></td>
      <td><p>Bottom row in the range.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">rightCol</span></td>
      <td><p>Right column in the range.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">extraSpace</span></td>
      <td><p>Amount of extra space, in pixels, to add to the column widths.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="C1.Win.FlexGrid.AutoSizeFlags.html">AutoSizeFlags</a></td>
      <td><span class="parametername">flags</span></td>
      <td><p>Flags that control auto-sizing options.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Win_FlexGrid_C1FlexGridBase_AutoSizeCols_System_Int32_System_Int32_System_Int32_System_Int32_System_Int32_C1_Win_FlexGrid_AutoSizeFlags__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>By default, the <a class="xref" href="C1.Win.FlexGrid.C1FlexGridBase.AutoSizeCols.html#C1_Win_FlexGrid_C1FlexGridBase_AutoSizeCols_System_Int32_System_Int32_System_Int32_System_Int32_System_Int32_C1_Win_FlexGrid_AutoSizeFlags_">AutoSizeCols(int, int, int, int, int, AutoSizeFlags)</a> method measures every cell in each column, 
taking into account the cell contents and style.</p>
<p>If the grid has a large number of rows, you can improve performance by using the 
<code class="paramref">topRow</code> and <code class="paramref">bottomRow</code> parameters to specify a row range. 
You can include only a few hundred rows in the process, and add some extra spacing for safety.</p>
</div>


<a id="C1_Win_FlexGrid_C1FlexGridBase_AutoSizeCols_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.AutoSizeCols*"></a>
<h4 id="C1_Win_FlexGrid_C1FlexGridBase_AutoSizeCols" data-uid="C1.Win.FlexGrid.C1FlexGridBase.AutoSizeCols">AutoSizeCols()</h4>
<div class="markdown level1 summary"><p>Adjusts the width of all columns to fit the data.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public virtual void AutoSizeCols()</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Overridable Sub AutoSizeCols()</code></pre>
</div>


<a id="C1_Win_FlexGrid_C1FlexGridBase_AutoSizeCols_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.AutoSizeCols*"></a>
<h4 id="C1_Win_FlexGrid_C1FlexGridBase_AutoSizeCols_System_Int32_System_Int32_System_Int32_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.AutoSizeCols(System.Int32,System.Int32,System.Int32)">AutoSizeCols(int, int, int)</h4>
<div class="markdown level1 summary"><p>Adjusts the width of columns in a range to fit the data.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public virtual void AutoSizeCols(int leftCol, int rightCol, int extraSpace)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Overridable Sub AutoSizeCols(leftCol As Integer, rightCol As Integer, extraSpace As Integer)</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.int32">int</a></td>
      <td><span class="parametername">leftCol</span></td>
      <td><p>Left column in the range.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">rightCol</span></td>
      <td><p>Right column in the range.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">extraSpace</span></td>
      <td><p>Amount of extra space, in pixels, to add to the column widths.</p>
</td>
    </tr>
  </tbody>
</table>


<a id="C1_Win_FlexGrid_C1FlexGridBase_AutoSizeCols_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.AutoSizeCols*"></a>
<h4 id="C1_Win_FlexGrid_C1FlexGridBase_AutoSizeCols_System_Int32_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.AutoSizeCols(System.Int32)">AutoSizeCols(int)</h4>
<div class="markdown level1 summary"><p>Adjusts the width of all columns fit the data.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public virtual void AutoSizeCols(int extraSpace)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Overridable Sub AutoSizeCols(extraSpace As Integer)</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.int32">int</a></td>
      <td><span class="parametername">extraSpace</span></td>
      <td><p>Amount of extra space, in pixels, to add to the column widths.</p>
</td>
    </tr>
  </tbody>
</table>


<a id="C1_Win_FlexGrid_C1FlexGridBase_AutoSizeCols_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.AutoSizeCols*"></a>
<h4 id="C1_Win_FlexGrid_C1FlexGridBase_AutoSizeCols_System_Drawing_Graphics_System_Int32_System_Int32_System_Int32_System_Int32_System_Int32_C1_Win_FlexGrid_AutoSizeFlags_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.AutoSizeCols(System.Drawing.Graphics,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,C1.Win.FlexGrid.AutoSizeFlags)">AutoSizeCols(Graphics, int, int, int, int, int, AutoSizeFlags)</h4>
<div class="markdown level1 summary"><p>Automatically size grid columns to fit the largest entry.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">protected virtual void AutoSizeCols(Graphics g, int row1, int col1, int row2, int col2, int extra, AutoSizeFlags flags)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Protected Overridable Sub AutoSizeCols(g As Graphics, row1 As Integer, col1 As Integer, row2 As Integer, col2 As Integer, extra As Integer, flags As AutoSizeFlags)</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.drawing.graphics">Graphics</a></td>
      <td><span class="parametername">g</span></td>
      <td><p><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.graphics">Graphics</a> object used to measure the cell contents.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">row1</span></td>
      <td><p>Index of the first row to be measured.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">col1</span></td>
      <td><p>Index of the first column to be measured.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">row2</span></td>
      <td><p>Index of the last row to be measured.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">col2</span></td>
      <td><p>Index of the first column to be measured.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">extra</span></td>
      <td><p>Extra space, in twips, to add to the largest entry.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="C1.Win.FlexGrid.AutoSizeFlags.html">AutoSizeFlags</a></td>
      <td><span class="parametername">flags</span></td>
      <td><p><a class="xref" href="C1.Win.FlexGrid.AutoSizeFlags.html">AutoSizeFlags</a> value that specifies auto-sizing behavior.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Win_FlexGrid_C1FlexGridBase_AutoSizeCols_System_Drawing_Graphics_System_Int32_System_Int32_System_Int32_System_Int32_System_Int32_C1_Win_FlexGrid_AutoSizeFlags__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This method is for internal use. It allows inherited classes to customize the grid appearance.</p>
</div>
</div>
