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 表示顯示值的型別,null 則表示使用預設轉換子。A TypeConverter for the display value type, or null to use the default converter.

valueTypeConverter
TypeConverter TypeConverter TypeConverter TypeConverter

TypeConverter 表示儲存格值的型別,null 則表示使用預設轉換子。A 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控制項會呼叫這個方法,將顯示的值FormattedValueTypeValueType轉換成。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.

這個formattedValue方法的預設執行會cellStyle NullValue使用參數所指示的單元DataSourceNullValue格樣式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.

適用於

另請參閱