DataGridViewCell.ParseFormattedValue(Object, DataGridViewCellStyle, TypeConverter, TypeConverter) DataGridViewCell.ParseFormattedValue(Object, DataGridViewCellStyle, TypeConverter, TypeConverter) DataGridViewCell.ParseFormattedValue(Object, DataGridViewCellStyle, TypeConverter, TypeConverter) DataGridViewCell.ParseFormattedValue(Object, DataGridViewCellStyle, TypeConverter, TypeConverter) Method

定义

将为便于显示而进行了格式设置的值转换为实际的单元格值。Converts a value formatted for display to an actual cell value.

public:
 virtual System::Object ^ ParseFormattedValue(System::Object ^ formattedValue, System::Windows::Forms::DataGridViewCellStyle ^ cellStyle, System::ComponentModel::TypeConverter ^ formattedValueTypeConverter, System::ComponentModel::TypeConverter ^ valueTypeConverter);
public virtual object ParseFormattedValue (object formattedValue, System.Windows.Forms.DataGridViewCellStyle cellStyle, System.ComponentModel.TypeConverter formattedValueTypeConverter, System.ComponentModel.TypeConverter valueTypeConverter);
abstract member ParseFormattedValue : obj * System.Windows.Forms.DataGridViewCellStyle * System.ComponentModel.TypeConverter * System.ComponentModel.TypeConverter -> obj
override this.ParseFormattedValue : obj * System.Windows.Forms.DataGridViewCellStyle * System.ComponentModel.TypeConverter * System.ComponentModel.TypeConverter -> obj
Public Overridable Function ParseFormattedValue (formattedValue As Object, cellStyle As DataGridViewCellStyle, formattedValueTypeConverter As TypeConverter, valueTypeConverter As TypeConverter) As Object

参数

formattedValue
Object Object Object Object

单元格的显示值。The display value of the cell.

formattedValueTypeConverter
TypeConverter TypeConverter TypeConverter TypeConverter

显示值类型的 TypeConverter;如果使用默认转换器,则为 nullA TypeConverter for the display value type, or null to use the default converter.

valueTypeConverter
TypeConverter TypeConverter TypeConverter TypeConverter

单元格值类型的 TypeConverter;若要使用默认转换器,则为 nullA TypeConverter for the cell value type, or null to use the default converter.

返回

单元格值。The cell value.

异常

FormattedValueType 属性值为 nullThe FormattedValueType property value is null.

- 或 --or- ValueType 属性值为 nullThe ValueType property value is null.

- 或 --or- 无法转换 formattedValueformattedValue cannot be converted.

formattedValuenullformattedValue is null.

- 或 --or- formattedValue 的类型与 FormattedValueType 属性指示的类型不匹配。The type of formattedValue does not match the type indicated by the FormattedValueType property.

注解

当用户编辑单元格的值,并提交更改,DataGridView控件将调用此方法将从显示的值FormattedValueTypeValueTypeWhen 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.

此方法的默认实现将分析formattedValue参数使用NullValueDataSourceNullValue,和FormatProvider单元格样式的属性由cellStyle参数。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.

如果formattedValue等同于NullValue,此方法返回的值DataSourceNullValue属性或null如果DataSourceNullValueDBNull.Value和单元格ValueType是引用类型。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.

如果formattedValue不等于NullValue,此方法分析formattedValue使用FormatProvider属性和指定或默认的转换器。If formattedValue is not equal to NullValue, this method parses formattedValue using the FormatProvider property and the specified or default converters.

如果该单元格ValueType是可以为 null,此方法会包装返回的值作为Nullable<T>类型。If the cell ValueType is nullable, this method wraps the return value as a Nullable<T> type.

适用于

另请参阅