# C1.Win.FlexGrid.OwnerDrawCellEventArgs.Style

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_Win_FlexGrid_OwnerDrawCellEventArgs_Style_" data-uid="C1.Win.FlexGrid.OwnerDrawCellEventArgs.Style*">Style Property
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_Win_FlexGrid_OwnerDrawCellEventArgs_Style_" data-uid="C1.Win.FlexGrid.OwnerDrawCellEventArgs.Style*"></a>
<h4 id="C1_Win_FlexGrid_OwnerDrawCellEventArgs_Style" data-uid="C1.Win.FlexGrid.OwnerDrawCellEventArgs.Style">Style</h4>
<div class="markdown level1 summary"><p>Sets or sets the <a class="xref" href="C1.Win.FlexGrid.CellStyle.html">CellStyle</a> object used to paint the cell.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public CellStyle Style { get; set; }</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Property Style As CellStyle</code></pre>
</div>
<h5 id="C1_Win_FlexGrid_OwnerDrawCellEventArgs_Style_remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This parameter is often used to provide dynamic formatting based on cell contents. For example,
if the cell contains a value outside a given range, the event handler may assign a new style to
this parameter.</p>
<p>Although it is legal to modify the members of the <a class="xref" href="C1.Win.FlexGrid.CellStyle.html">CellStyle</a> parameter in this
event, this is not recommended, since the change will affect other cells that may be using this style.</p>
</div>
<h5 id="C1_Win_FlexGrid_OwnerDrawCellEventArgs_Style_examples">Examples</h5>
<p>The code below uses the <a class="xref" href="C1.Win.FlexGrid.C1FlexGridBase.OwnerDrawCell.html">OwnerDrawCell</a> event to highlight cells that
indicate low stock levels.</p>
<pre><code class="lang-csharp">// create style used to display low-stock items
CellStyle cs = _flex.Styles.Add("Critical");
cs.BackColor = Color.Red;
private void _flex_OwnerDrawCell(object sender, OwnerDrawCellEventArgs e)
{
    // ignore fixed cells
    if (e.Row &lt; _flex.Rows.Fixed || e.Col &lt; _flex.Cols.Fixed)
        return;

    // apply custom style if reorder level is critical
    if (_flex.Cols[e.Col].Name == "UnitsInStock")
    {
        // change the style by applying the "Critical" style to the Style parameter
        // (do not change the e.Style.BackColor property directly since that would
        // affect other cells that use this style)
        if ((short)_flex[e.Row, "UnitsInStock"] &lt; (short)_flex[e.Row, "ReorderLevel"])
            e.Style = _flex.Styles["Critical"];
    }
}</code></pre>

</div>
