# C1.Win.FlexGrid.C1FlexGridBase.ColSel

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_Win_FlexGrid_C1FlexGridBase_ColSel_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.ColSel*">ColSel Property
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_Win_FlexGrid_C1FlexGridBase_ColSel_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.ColSel*"></a>
<h4 id="C1_Win_FlexGrid_C1FlexGridBase_ColSel" data-uid="C1.Win.FlexGrid.C1FlexGridBase.ColSel">ColSel</h4>
<div class="markdown level1 summary"><p>Gets or sets the last column in the current selection.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">[Browsable(false)]
public int ColSel { get; set; }</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">&lt;Browsable(False)&gt;
Public Property ColSel As Integer</code></pre>
</div>
<h5 id="C1_Win_FlexGrid_C1FlexGridBase_ColSel_remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>Use the <a class="xref" href="C1.Win.FlexGrid.C1FlexGridBase.RowSel.html#C1_Win_FlexGrid_C1FlexGridBase_RowSel">RowSel</a> and <a class="xref" href="C1.Win.FlexGrid.C1FlexGridBase.ColSel.html#C1_Win_FlexGrid_C1FlexGridBase_ColSel">ColSel</a> properties to modify a 
selection or to determine which cells are currently selected. Columns and rows are 
numbered from zero, beginning at the top for rows and at the left for columns.</p>
<p>Setting the <a class="xref" href="C1.Win.FlexGrid.C1FlexGridBase.Row.html#C1_Win_FlexGrid_C1FlexGridBase_Row">Row</a> and <a class="xref" href="C1.Win.FlexGrid.C1FlexGridBase.Col.html#C1_Win_FlexGrid_C1FlexGridBase_Col">Col</a> properties automatically 
collapses the selection to a single cell, resetting the RowSel and ColSel properties. 
Therefore, to specify a block selection, you must Row and Col, then RowSel and ColSel. 
Alternatively, you may use the <a class="xref" href="C1.Win.FlexGrid.C1FlexGridBase.Select.html#C1_Win_FlexGrid_C1FlexGridBase_Select_C1_Win_FlexGrid_CellRange_System_Boolean_">Select(CellRange, bool)</a> method to select a range with a 
single statement.</p>
<p>When a range is selected, the value of <a class="xref" href="C1.Win.FlexGrid.C1FlexGridBase.Row.html#C1_Win_FlexGrid_C1FlexGridBase_Row">Row</a> may be greater than or 
less than <a class="xref" href="C1.Win.FlexGrid.C1FlexGridBase.RowSel.html#C1_Win_FlexGrid_C1FlexGridBase_RowSel">RowSel</a>, and <a class="xref" href="C1.Win.FlexGrid.C1FlexGridBase.Col.html#C1_Win_FlexGrid_C1FlexGridBase_Col">Col</a> may be greater than or less than <a class="xref" href="C1.Win.FlexGrid.C1FlexGridBase.ColSel.html#C1_Win_FlexGrid_C1FlexGridBase_ColSel">ColSel</a>.
This is inconvenient when you need to set up bounds for loops. In these cases, you can 
use the <a class="xref" href="C1.Win.FlexGrid.C1FlexGridBase.Selection.html#C1_Win_FlexGrid_C1FlexGridBase_Selection">Selection</a> property to retrieve a normalized <a class="xref" href="C1.Win.FlexGrid.CellRange.html">CellRange</a> 
object, where r1 &lt;= r2 and c1 &lt;= c2.</p>
</div>
<h5 id="C1_Win_FlexGrid_C1FlexGridBase_ColSel_examples">Examples</h5>
<p>The code below loops though the cells in the current selection:</p>
<pre><code class="lang-csharp">CellRange rg = flex.Selection;
for (int r = rg.r1; r &lt;= rg.r2; r++)
  for (int c = rg.c1; c &lt;= rg.c2; c++)
    Console.WriteLine("the value at {0} {1} is {2}", r, c, flex[r, c]);</code></pre>

</div>
