Export (0) Print
Expand All
Expand Minimize

DataGridViewCell.ParseFormattedValue Method

Converts a value formatted for display to an actual cell value.

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

public virtual Object ParseFormattedValue(
	Object formattedValue,
	DataGridViewCellStyle cellStyle,
	TypeConverter formattedValueTypeConverter,
	TypeConverter valueTypeConverter


Type: System.Object

The display value of the cell.

Type: System.Windows.Forms.DataGridViewCellStyle

The DataGridViewCellStyle in effect for the cell.

Type: System.ComponentModel.TypeConverter

A TypeConverter for the display value type, or null to use the default converter.

Type: System.ComponentModel.TypeConverter

A TypeConverter for the cell value type, or null to use the default converter.

Return Value

Type: System.Object
The cell value.


cellStyle is null.


The FormattedValueType property value is null.


The ValueType property value is null.


formattedValue cannot be converted.


formattedValue is null.


The type of formattedValue does not match the type indicated by the FormattedValueType property.

When the user edits a cell value and commits the change, the DataGridView control calls this method to convert the displayed value from the FormattedValueType to the ValueType. The control then sets the underlying cell value or data source value to the converted value.

The default implementation of this method parses the formattedValue parameter using the NullValue, DataSourceNullValue, and FormatProvider properties of the cell style indicated by the cellStyle parameter.

If formattedValue is equal to NullValue, this method returns the value of the DataSourceNullValue property or null if DataSourceNullValue is DBNull.Value and the cell ValueType is a reference type.

If formattedValue is not equal to NullValue, this method parses formattedValue using the FormatProvider property and the specified or default converters.

If the cell ValueType is nullable, this method wraps the return value as a Nullable<T> type.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft