DataGridViewCellParsingEventArgs.ColumnIndex Property
.NET Framework 2.0
Note: This property is new in the .NET Framework version 2.0.
Gets the column index of the cell data that requires parsing.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)
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. 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; } } } } }
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.