# C1.Win.FlexGrid.C1FlexGridBase.ValidateEdit

## Content

<div class="doc-site-dotnet-api-container">




<h1 id="C1_Win_FlexGrid_C1FlexGridBase_ValidateEdit" data-uid="C1.Win.FlexGrid.C1FlexGridBase.ValidateEdit" class="text-break">ValidateEdit Event
</h1>
<div class="markdown level0 summary"><p>Fires before the control exits cell edit mode, while the editor is still active.</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_ValidateEdit_syntax">Syntax</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public event ValidateEditEventHandler ValidateEdit</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Event ValidateEdit As ValidateEditEventHandler</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.ValidateEditEventHandler.html">ValidateEditEventHandler</a></td>
      <td>Fires before the control exits cell edit mode, while the editor is still active.</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Win_FlexGrid_C1FlexGridBase_ValidateEdit_remarks"><strong>Remarks</strong></h5>
<div class="markdown level0 remarks"><p>When this event fires, the contents of the editor have not been applied to the 
grid. You can validate the editor contents and cancel the edits if necessary.</p>
<p>To validate the editor contents, check the value contained in the <b>Editor.Text</b> 
property. If the value is invalid for the cell, set the <b>Cancel</b> parameter to true 
and the grid will remain in edit mode until the user types a valid entry.</p>
<example>
For example, the code below checks to make sure the value entered is an integer
between 0 and 100:
<pre><code class="lang-csharp">void _flex_ValidateEdit(object sender, ValidateEditEventArgs e)
{
    if (_flex.Cols[e.Col].Name = "Score")
    {
        try
        {
            int value = int.Parse(_flex.Editor.Text);
            if (value &gt;= 0 &amp;&amp; value &lt;= 50)
                return; // accept edits
        }
        catch {}
<pre><code>    // error or invalid range, refuse edits
    e.Cancel = true;
}
</code></pre>
<p>}</p></code></pre>
</example>
</div>
</div>
