DataGridViewCellParsingEventArgs.ParsingApplied Property

 

Gets or sets a value indicating whether a cell's value has been successfully parsed.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public bool ParsingApplied { get; set; }

Property Value

Type: System.Boolean

true if the cell's value has been successfully parsed; otherwise, false. The default is false.

A DataGridViewCellParsingEventHandler sets the ParsingApplied property to indicate whether the new cell value was successfully parsed and no further conversion is necessary.

The following code example sets ParsingApplied to true when the cell's value is successfully parsed.

// Handling CellParsing allows one to accept user input, then map it to a different
// internal representation.
private void dataGridView1_CellParsing(object sender, DataGridViewCellParsingEventArgs e)
{
    if (this.dataGridView1.Columns[e.ColumnIndex].Name == "Release Date")
    {
        if (e != null)
        {
            if (e.Value != null)
            {
                try
                {
                    // Map what the user typed into UTC.
                    e.Value = DateTime.Parse(e.Value.ToString()).ToUniversalTime();
                    // Set the ParsingApplied property to 
                    // Show the event is handled.
                    e.ParsingApplied = true;

                }
                catch (FormatException)
                {
                    // Set to false in case another CellParsing handler
                    // wants to try to parse this DataGridViewCellParsingEventArgs instance.
                    e.ParsingApplied = false;
                }
            }
        }
    }
}

.NET Framework
Available since 2.0
Return to top
Show: