DataGridViewCellParsingEventArgs::ColumnIndex Property
.NET Framework (current version)
Gets the column index of the cell data that requires parsing.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Use the ColumnIndex property to obtain an index into the Columns property of a DataGridView.
The following code example demonstrates using ColumnIndex to discover if the changed cell is in the date column.
// 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
Available since 2.0
Show: