DataGridViewCell::ParseFormattedValue Method (Object^, DataGridViewCellStyle^, TypeConverter^, TypeConverter^)
Converts a value formatted for display to an actual cell value.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
public: virtual Object^ ParseFormattedValue( Object^ formattedValue, DataGridViewCellStyle^ cellStyle, TypeConverter^ formattedValueTypeConverter, TypeConverter^ valueTypeConverter )
Parameters
- formattedValue
-
Type:
System::Object^
The display value of the cell.
- cellStyle
-
Type:
System.Windows.Forms::DataGridViewCellStyle^
The DataGridViewCellStyle in effect for the cell.
- formattedValueTypeConverter
-
Type:
System.ComponentModel::TypeConverter^
A TypeConverter for the display value type, or null to use the default converter.
- valueTypeConverter
-
Type:
System.ComponentModel::TypeConverter^
A TypeConverter for the cell value type, or null to use the default converter.
| Exception | Condition |
|---|---|
| ArgumentNullException | cellStyle is null. |
| FormatException | The FormattedValueType property value is null. -or- The ValueType property value is null. -or- formattedValue cannot be converted. |
| ArgumentException | formattedValue is null. -or- 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.
Available since 2.0
DataGridView
DataGridViewCellStyle
DataGridViewCellStyle::NullValue
DataGridViewCellStyle::DataSourceNullValue
DataGridViewCellStyle::FormatProvider
ValueType
GetFormattedValue
Nullable<T>
DataGridViewCell Class
System.Windows.Forms Namespace
Nullable Types (C# Programming Guide)
Nullable Value Types (Visual Basic)