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:
property bool ParsingApplied {
	bool get();
	void set(bool value);
}

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.
void dataGridView1_CellParsing( Object^ /*sender*/, DataGridViewCellParsingEventArgs^ e )
{
   if ( this->dataGridView1->Columns[ e->ColumnIndex ]->Name->Equals( "Release Date" ) )
   {
      if ( e != nullptr )
      {
         if ( e->Value != nullptr )
         {
            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^ /*ex*/ ) 
            {
               // 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: