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控件将调用此方法以将显示的值FormattedValueType从转换为ValueTypeWhen 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 DataSourceNullValue NullValue参数cellStyle指示的单元格样式的、 FormatProvider和属性分析参数。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 null DataSourceNullValue ValueType DBNull.Value等于,则此方法将返回属性的值; 如果DataSourceNullValue为,则该单元格为引用类型。 NullValueIf 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.

如果formattedValueformattedValue 等于,则FormatProvider此方法使用属性和指定的或默认的转换器进行分析。 NullValueIf 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.

适用于

另请参阅