DataGridViewComboBoxCell.GetFormattedValue メソッド

定義

セルのデータの書式指定済みの値を取得します。

protected:
 override System::Object ^ GetFormattedValue(System::Object ^ value, int rowIndex, System::Windows::Forms::DataGridViewCellStyle ^ % cellStyle, System::ComponentModel::TypeConverter ^ valueTypeConverter, System::ComponentModel::TypeConverter ^ formattedValueTypeConverter, System::Windows::Forms::DataGridViewDataErrorContexts context);
protected override object GetFormattedValue (object value, int rowIndex, ref System.Windows.Forms.DataGridViewCellStyle cellStyle, System.ComponentModel.TypeConverter valueTypeConverter, System.ComponentModel.TypeConverter formattedValueTypeConverter, System.Windows.Forms.DataGridViewDataErrorContexts context);
protected override object? GetFormattedValue (object? value, int rowIndex, ref System.Windows.Forms.DataGridViewCellStyle cellStyle, System.ComponentModel.TypeConverter? valueTypeConverter, System.ComponentModel.TypeConverter? formattedValueTypeConverter, System.Windows.Forms.DataGridViewDataErrorContexts context);
override this.GetFormattedValue : obj * int * DataGridViewCellStyle * System.ComponentModel.TypeConverter * System.ComponentModel.TypeConverter * System.Windows.Forms.DataGridViewDataErrorContexts -> obj
Protected Overrides Function GetFormattedValue (value As Object, rowIndex As Integer, ByRef cellStyle As DataGridViewCellStyle, valueTypeConverter As TypeConverter, formattedValueTypeConverter As TypeConverter, context As DataGridViewDataErrorContexts) As Object

パラメーター

value
Object

書式指定される値。

rowIndex
Int32

セルの親行のインデックス。

cellStyle
DataGridViewCellStyle

セルに反映される DataGridViewCellStyle

valueTypeConverter
TypeConverter

書式指定済みの値の型へカスタムの変換を実行する、元の値の型に関連付けられた TypeConverter。カスタムの変換が不要な場合は null

formattedValueTypeConverter
TypeConverter

書式指定済みの値の型からカスタムの変換を実行する、その値の型に関連付けられた TypeConverter。カスタムの変換が不要な場合は null

context
DataGridViewDataErrorContexts

書式指定済みの値が必要とされているコンテキストを示す DataGridViewDataErrorContexts 値のビットごとの組み合わせ。

戻り値

書式指定適用後のセルのデータの値。セルが DataGridView コントロールに含まれていない場合は null

例外

書式指定が失敗し、DataError コントロールの DataGridView イベントのハンドラーが定義されていないか、ハンドラーで ThrowException プロパティが true に設定されました。 この例外オブジェクトは、通常、型変換エラーの場合は FormatException 型、valueArgumentException または DataSource コレクションに存在しない場合は Items 型にキャストできます。

注釈

コントロールは DataGridView 、このメソッドを呼び出して、セル値を プロパティによって示される型の同等の表示値に FormattedValueType 変換します。 コントロールは、 パラメーター内のこのメソッドにセル値を value 渡します。

このメソッドは、次のいずれかの条件が満たされているかどうかを判断することによって、最初に が有効かどうかを判断 value します。

が無効な場合 value 、イベントが DataGridView.DataError 発生します。 このイベントのハンドラーがない場合、またはハンドラーによって プロパティが DataGridViewDataErrorEventArgs.ThrowExceptiontrue設定されている場合は、例外がスローされます。

が有効であるか、イベントのハンドラーがあり、 DataError プロパティが にtrue設定DataGridViewDataErrorEventArgs.ThrowExceptionされていない場合value、イベントがDataGridView.CellFormatting発生します。

イベント ハンドラーでは CellFormatting 、 と の両方 valuecellStyle変更できます。 ただし、ハンドラーで プロパティが DataGridViewCellFormattingEventArgs.FormattingAppliedtrue設定されていない場合、このメソッド value は オブジェクトの書式設定プロパティを使用して書式を cellStyle 設定します。 これにより、追加 DataError のイベントが発生する可能性があります。

書式設定が成功した場合、このメソッドはコントロールに表示する書式設定された値を DataGridView 返します。

適用対象

こちらもご覧ください