DataGridViewCheckBoxCell.GetFormattedValue メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DataGridViewCheckBoxCell.GetFormattedValue メソッドの意味・解説 

DataGridViewCheckBoxCell.GetFormattedValue メソッド

メモ : このメソッドは、.NET Framework version 2.0 で新しく追加されたものです。

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

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

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
Dim value As Object
Dim rowIndex As Integer
Dim cellStyle As DataGridViewCellStyle
Dim valueTypeConverter As TypeConverter
Dim formattedValueTypeConverter As TypeConverter
Dim context As DataGridViewDataErrorContexts
Dim returnValue As Object

returnValue = Me.GetFormattedValue(value, rowIndex, cellStyle,
 valueTypeConverter, formattedValueTypeConverter, context)
protected override Object GetFormattedValue (
    Object value,
    int rowIndex,
    ref DataGridViewCellStyle cellStyle,
    TypeConverter valueTypeConverter,
    TypeConverter formattedValueTypeConverter,
    DataGridViewDataErrorContexts context
)
protected:
virtual Object^ GetFormattedValue (
    Object^ value, 
    int rowIndex, 
    DataGridViewCellStyle^% cellStyle, 
    TypeConverter^ valueTypeConverter, 
    TypeConverter^ formattedValueTypeConverter, 
    DataGridViewDataErrorContexts context
) override
protected Object GetFormattedValue (
    Object value, 
    int rowIndex, 
    /** @ref */ DataGridViewCellStyle cellStyle, 
    TypeConverter valueTypeConverter, 
    TypeConverter formattedValueTypeConverter, 
    DataGridViewDataErrorContexts context
)
JScript では、値型の引数は参照渡しされません。

パラメータ

value

書式設定される値。

rowIndex

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

cellStyle

セルに反映される DataGridViewCellStyle。

valueTypeConverter

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

formattedValueTypeConverter

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

context

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

戻り値
書式設定が適用された後のセルの値。セルが DataGridView コントロールの一部ではない場合は null 参照 (Visual Basic では Nothing)。

解説解説

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

このメソッドは、まず、value を Boolean 値 (TrueValue、FalseValue、IndeterminateValue のいずれかのプロパティが設定されている場合は、CheckState 値) に変換します。

変換に失敗すると、DataGridView.DataError イベントが発生します。このイベントのハンドラがない場合や、ハンドラで DataGridViewDataErrorEventArgs.ThrowException プロパティを true に設定している場合、例外がスローされます。

変換に成功した場合、または、DataError イベントのハンドラが存在していて、なおかつ、DataGridViewDataErrorEventArgs.ThrowException プロパティが true に設定されていない場合は、DataGridView.CellFormatting イベントが発生します。

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

書式設定に成功し、context パラメータに ClipboardContent 値が含まれていた場合、このメソッドは、クリップボードにコピーするための書式設定済みの値を String 型にして返します。それ以外の場合は、DataGridView コントロールで表示される書式設定済みの値が返されます。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataGridViewCheckBoxCell クラス
DataGridViewCheckBoxCell メンバ
System.Windows.Forms 名前空間
FormattedValueType
DataGridView クラス
DataGridView.DataError イベント
DataGridViewCellStyle クラス
DataGridViewCellStyle.Format プロパティ
TypeConverter
DataGridViewDataErrorContexts
Boolean
CheckState 列挙体
TrueValue
FalseValue
IndeterminateValue
DataGridView.CellFormatting イベント



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

DataGridViewCheckBoxCell.GetFormattedValue メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DataGridViewCheckBoxCell.GetFormattedValue メソッドのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS