System.Windows.Forms.DataGridViewCell.ParseFormattedValue Method

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

Syntax

public virtual object ParseFormattedValue (object formattedValue, DataGridViewCellStyle cellStyle, System.ComponentModel.TypeConverter formattedValueTypeConverter, System.ComponentModel.TypeConverter valueTypeConverter)

Parameters

formattedValue
The display value of the cell.
cellStyle
The System.Windows.Forms.DataGridViewCellStyle in effect for the cell.
formattedValueTypeConverter
A System.ComponentModel.TypeConverter for the display value type, or null to use the default converter.
valueTypeConverter
A System.ComponentModel.TypeConverter for the cell value type, or null to use the default converter.

Returns

The cell value.

Remarks

When the user edits a cell value and commits the change, the System.Windows.Forms.DataGridView control calls this method to convert the displayed value from the DataGridViewCell.FormattedValueType to the DataGridViewCell.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 DataGridViewCellStyle.NullValue, DataGridViewCellStyle.DataSourceNullValue, and DataGridViewCellStyle.FormatProvider properties of the cell style indicated by the cellStyle parameter.

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

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

If the cell DataGridViewCell.ValueType is nullable, this method wraps the return value as a Nullable`1 type.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0