DataGridViewCellParsingEventArgs Class


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Provides data for the CellParsing event of a DataGridView control.

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


type DataGridViewCellParsingEventArgs = 
        inherit ConvertEventArgs

System_CAPS_pubmethodDataGridViewCellParsingEventArgs(Int32, Int32, Object, Type, DataGridViewCellStyle)

Initializes a new instance of the DataGridViewCellParsingEventArgs class.


Gets the column index of the cell data that requires parsing.


Gets the data type of the desired value.(Inherited from ConvertEventArgs.)


Gets or sets the style applied to the edited cell.


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


Gets the row index of the cell that requires parsing.


Gets or sets the value of the ConvertEventArgs.(Inherited from ConvertEventArgs.)


Determines whether the specified object is equal to the current object.(Inherited from Object.)


Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)


Serves as the default hash function. (Inherited from Object.)


Gets the Type of the current instance.(Inherited from Object.)


Creates a shallow copy of the current Object.(Inherited from Object.)


Returns a string that represents the current object.(Inherited from Object.)

Handle the CellParsing event to provide custom value conversion from a user-specified value to a value in the type specified by the cell ValueType property.

When you handle the CellParsing event, you can convert the value yourself or you can customize the default conversion. For example, you can convert the value yourself using the cell ParseFormattedValue method with type converters of your choosing. Alternately, you can let the default type converters parse the value, but modify the NullValue, DataSourceNullValue, and FormatProvider properties of the object returned by the DataGridViewCellParsingEventArgs.InheritedCellStyle property, which is initialized using the cell InheritedStyle property.

When you convert the value yourself, replace the initial, formatted value of the ConvertEventArgs.Value property with the converted value in the type specified by the cell ValueType property. To indicate that no further parsing is necessary, set the DataGridViewCellParsingEventArgs.ParsingApplied property to true.

When the event handler completes, if the Value is null or is not of the correct type, or the ParsingApplied property is false, the Value is parsed using the cell ParseFormattedValue method with default type converters. The default implementation of this method parses the value using the NullValue, DataSourceNullValue, and FormatProvider properties of the cell style passed in. If the value is not equal to NullValue, the value is parsed using the FormatProvider property and the type converters passed in.

To customize the conversion of a cell value into a formatted value for display, handle the CellFormatting event.

For more information about handling events, see NIB: Consuming Events.

The following code example demonstrates using DataGridViewCellParsingEventArgs to check the validity of date entries.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top