# C1.Win.FlexGrid.C1FlexGridBase.OwnerDrawCell

## Content

<div class="doc-site-dotnet-api-container">




<h1 id="C1_Win_FlexGrid_C1FlexGridBase_OwnerDrawCell" data-uid="C1.Win.FlexGrid.C1FlexGridBase.OwnerDrawCell" class="text-break">OwnerDrawCell Event
</h1>
<div class="markdown level0 summary"><p>Fires before the grid draws a cell, when the <a class="xref" href="C1.Win.FlexGrid.C1FlexGridBase.DrawMode.html#C1_Win_FlexGrid_C1FlexGridBase_DrawMode">DrawMode</a> property is set to <a class="xref" href="C1.Win.FlexGrid.DrawModeEnum.html#C1_Win_FlexGrid_DrawModeEnum_OwnerDraw">OwnerDraw</a>.</p>
</div>
<div class="markdown level0 conceptual"></div>
<h6><strong>Namespace</strong>: <a class="xref" href="C1.Win.FlexGrid.html">C1.Win.FlexGrid</a></h6>
<h6><strong>Assembly</strong>: C1.Win.FlexGrid.10.dll</h6>
<h5 id="C1_Win_FlexGrid_C1FlexGridBase_OwnerDrawCell_syntax">Syntax</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public event OwnerDrawCellEventHandler OwnerDrawCell</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Event OwnerDrawCell As OwnerDrawCellEventHandler</code></pre>
</div>
<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.OwnerDrawCellEventHandler.html">OwnerDrawCellEventHandler</a></td>
      <td>Fires before the grid draws a cell, when the  property is set to .</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Win_FlexGrid_C1FlexGridBase_OwnerDrawCell_remarks"><strong>Remarks</strong></h5>
<div class="markdown level0 remarks"><p>The <b>OwnerDrawCell</b> event only fires when the <a class="xref" href="C1.Win.FlexGrid.C1FlexGridBase.DrawMode.html#C1_Win_FlexGrid_C1FlexGridBase_DrawMode">DrawMode</a> property is 
set to <a class="xref" href="C1.Win.FlexGrid.DrawModeEnum.html#C1_Win_FlexGrid_DrawModeEnum_OwnerDraw">OwnerDraw</a>.</p>
<p>You can use this event to customize the appearance of any cell in the grid. 
The event allows three main types of customization:</p>
<ol><li><span class="term"></span>
Change the value of the <b>Text</b> and <b>Image</b> parameters to modify the values displayed 
by the grid. You can use this type of customization to replace password strings with asterisks, 
for example.</li><li><span class="term"></span>
Change the <b>Style</b> property to display the cell using a different style than the one 
selected by the grid by default. You can use this type of customization to provide conditional 
formatting, for example.</li><li><span class="term"></span>
Use the <b>Graphics</b> and <b>Bounds</b> parameters and draw the cell yourself. When drawing 
cells this way, you may call the <a class="xref" href="C1.Win.FlexGrid.OwnerDrawCellEventArgs.DrawCell.html#C1_Win_FlexGrid_OwnerDrawCellEventArgs_DrawCell_C1_Win_FlexGrid_DrawCellFlags_">DrawCell(DrawCellFlags)</a> member to force 
the grid to draw specific parts of the cell, while your code draws other parts. For example, 
you could paint a custom background and then call <b>DrawCell</b> to have the grid paint the cell
border and contents.
</li></ol>
<p>The <b>OwnerDrawCell</b> event also fires when the grid auto sizes rows or columns (see the 
<a class="xref" href="C1.Win.FlexGrid.C1FlexGridBase.AutoSizeRows.html#C1_Win_FlexGrid_C1FlexGridBase_AutoSizeRows_System_Int32_System_Int32_System_Int32_System_Int32_System_Int32_C1_Win_FlexGrid_AutoSizeFlags_">AutoSizeRows(int, int, int, int, int, AutoSizeFlags)</a> and <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> methods). This is done because the 
grid needs to measure the cell using the same text, image, and style parameters that are used to 
render it. In these cases, the <b>Measuring</b> parameter is set to true and the <b>Bounds</b>
rectangle is empty.</p>
</div>
</div>
