DataGridViewCellParsingEventArgs クラス
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)


ユーザーが指定した値から、セルの ValueType プロパティで指定された型の値へカスタム値変換を行うには、CellParsing イベントを処理します。
CellParsing イベントを処理する場合、値を自分で変換するか、既定の変換をカスタマイズできます。たとえば、セルの ParseFormattedValue メソッドと選択した型コンバータを使用して、値を自分で変更できます。または、既定の型コンバータに値を解析させる一方で、セルの InheritedStyle プロパティを使用して初期化される DataGridViewCellParsingEventArgs.InheritedCellStyle プロパティによって返されたオブジェクトの NullValue、DataSourceNullValue、および FormatProvider の各プロパティを変更できます。
値を自分で変換する場合は、ConvertEventArgs.Value プロパティの書式設定された最初の値を、セルの ValueType プロパティで指定された型の変換後の値に置換します。解析が不要になったことを指定するには、DataGridViewCellParsingEventArgs.ParsingApplied プロパティを true に設定します。
イベント ハンドラが完了したときに、Value が null 参照 (Visual Basic では Nothing) になっているか、正しい型ではない場合、または ParsingApplied プロパティが false の場合、Value は、セルの ParseFormattedValue メソッドと既定の型コンバータを使用して解析されます。このメソッドの既定の実装は、渡されたセル スタイルの NullValue、DataSourceNullValue、および FormatProvider の各プロパティを使用して値を解析します。値が NullValue でない場合、その値は、渡された FormatProvider プロパティと型コンバータを使用して解析されます。
セル値を、表示に合わせて書式設定された値に変換するときにカスタマイズを適用するには、CellFormatting イベントを処理します。

DataGridViewCellParsingEventArgs を使用して日付エントリの有効性を確認するコード例を次に示します。
' Handling CellParsing allows one to accept user input, then map it to a different ' internal representation. Private Sub dataGridView1_CellParsing(ByVal sender As Object, _ ByVal e As DataGridViewCellParsingEventArgs) _ Handles dataGridView1.CellParsing If Me.dataGridView1.Columns(e.ColumnIndex).Name = _ "Release Date" Then If e IsNot Nothing Then If e.Value IsNot Nothing Then Try ' Map what the user typed into UTC. e.Value = _ DateTime.Parse(e.Value.ToString()).ToUniversalTime() ' Set the ParsingApplied property to ' Show the event is handled. e.ParsingApplied = True Catch ex As FormatException ' Set to false in case another CellParsing handler ' wants to try to parse this DataGridViewCellParsingEventArgs instance. e.ParsingApplied = False End Try End If End If End If End Sub
// Handling CellParsing allows one to accept user input, then map it to a different // internal representation. private void dataGridView1_CellParsing(object sender, DataGridViewCellParsingEventArgs e) { if (this.dataGridView1.Columns[e.ColumnIndex].Name == "Release Date") { if (e != null) { if (e.Value != null) { try { // Map what the user typed into UTC. e.Value = DateTime.Parse(e.Value.ToString()).ToUniversalTime(); // Set the ParsingApplied property to // Show the event is handled. e.ParsingApplied = true; } catch (FormatException) { // Set to false in case another CellParsing handler // wants to try to parse this DataGridViewCellParsingEventArgs instance. e.ParsingApplied = false; } } } } }
// Handling CellParsing allows one to accept user input, then map it to a different // internal representation. void dataGridView1_CellParsing( Object^ /*sender*/, DataGridViewCellParsingEventArgs^ e ) { if ( this->dataGridView1->Columns[ e->ColumnIndex ]->Name->Equals( "Release Date" ) ) { if ( e != nullptr ) { if ( e->Value != nullptr ) { try { // Map what the user typed into UTC. e->Value = DateTime::Parse( e->Value->ToString() ).ToUniversalTime(); // Set the ParsingApplied property to // Show the event is handled. e->ParsingApplied = true; } catch ( FormatException^ /*ex*/ ) { // Set to false in case another CellParsing handler // wants to try to parse this DataGridViewCellParsingEventArgs instance. e->ParsingApplied = false; } } } } }

System.EventArgs
System.Windows.Forms.ConvertEventArgs
System.Windows.Forms.DataGridViewCellParsingEventArgs


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


DataGridViewCellParsingEventArgs メンバ
System.Windows.Forms 名前空間
DataGridView クラス
DataGridView.CellParsing イベント
DataGridView.OnCellParsing
DataGridView.CellFormatting イベント
DataGridView.EditMode プロパティ
DataGridViewCell.ValueType プロパティ
DataGridViewCell.InheritedStyle プロパティ
DataGridViewCell.ParseFormattedValue
DataGridViewCellParsingEventHandler
ConvertEventArgs.Value プロパティ
InheritedCellStyle
ParsingApplied
DataGridViewCellStyle
DataGridViewCellStyle.NullValue
DataGridViewCellStyle.Format
DataGridViewCellStyle.FormatProvider
DataGridViewCellParsingEventArgs コンストラクタ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Public Sub New ( _ rowIndex As Integer, _ columnIndex As Integer, _ value As Object, _ desiredType As Type, _ inheritedCellStyle As DataGridViewCellStyle _ )
Dim rowIndex As Integer Dim columnIndex As Integer Dim value As Object Dim desiredType As Type Dim inheritedCellStyle As DataGridViewCellStyle Dim instance As New DataGridViewCellParsingEventArgs(rowIndex, columnIndex, value, desiredType, inheritedCellStyle)
public DataGridViewCellParsingEventArgs ( int rowIndex, int columnIndex, Object value, Type desiredType, DataGridViewCellStyle inheritedCellStyle )
public: DataGridViewCellParsingEventArgs ( int rowIndex, int columnIndex, Object^ value, Type^ desiredType, DataGridViewCellStyle^ inheritedCellStyle )
public DataGridViewCellParsingEventArgs ( int rowIndex, int columnIndex, Object value, Type desiredType, DataGridViewCellStyle inheritedCellStyle )
public function DataGridViewCellParsingEventArgs ( rowIndex : int, columnIndex : int, value : Object, desiredType : Type, inheritedCellStyle : DataGridViewCellStyle )
- desiredType
新しい値の型。

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


DataGridViewCellParsingEventArgs プロパティ

名前 | 説明 | |
---|---|---|
![]() | ColumnIndex | 解析を必要とするセル データの列インデックスを取得します。 |
![]() | DesiredType | 必要な値のデータ型を取得します。 ( ConvertEventArgs から継承されます。) |
![]() | InheritedCellStyle | 編集されたセルに適用されるスタイルを取得または設定します。 |
![]() | ParsingApplied | セルの値が正常に解析されたかどうかを示す値を取得または設定します。 |
![]() | RowIndex | 解析を必要とするセルの行インデックスを取得します。 |
![]() | Value | ConvertEventArgs の値を取得または設定します。 ( ConvertEventArgs から継承されます。) |

関連項目
DataGridViewCellParsingEventArgs クラスSystem.Windows.Forms 名前空間
DataGridView クラス
DataGridView.CellParsing イベント
DataGridView.OnCellParsing
DataGridView.CellFormatting イベント
DataGridView.EditMode プロパティ
DataGridViewCell.ValueType プロパティ
DataGridViewCell.InheritedStyle プロパティ
DataGridViewCell.ParseFormattedValue
DataGridViewCellParsingEventHandler
ConvertEventArgs.Value プロパティ
InheritedCellStyle
ParsingApplied
DataGridViewCellStyle
DataGridViewCellStyle.NullValue
DataGridViewCellStyle.Format
DataGridViewCellStyle.FormatProvider
DataGridViewCellParsingEventArgs メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

関連項目
DataGridViewCellParsingEventArgs クラスSystem.Windows.Forms 名前空間
DataGridView クラス
DataGridView.CellParsing イベント
DataGridView.OnCellParsing
DataGridView.CellFormatting イベント
DataGridView.EditMode プロパティ
DataGridViewCell.ValueType プロパティ
DataGridViewCell.InheritedStyle プロパティ
DataGridViewCell.ParseFormattedValue
DataGridViewCellParsingEventHandler
ConvertEventArgs.Value プロパティ
InheritedCellStyle
ParsingApplied
DataGridViewCellStyle
DataGridViewCellStyle.NullValue
DataGridViewCellStyle.Format
DataGridViewCellStyle.FormatProvider
DataGridViewCellParsingEventArgs メンバ
DataGridView コントロールの CellParsing イベントのデータを提供します。
DataGridViewCellParsingEventArgs データ型で公開されるメンバを以下の表に示します。


名前 | 説明 | |
---|---|---|
![]() | ColumnIndex | 解析を必要とするセル データの列インデックスを取得します。 |
![]() | DesiredType | 必要な値のデータ型を取得します。(ConvertEventArgs から継承されます。) |
![]() | InheritedCellStyle | 編集されたセルに適用されるスタイルを取得または設定します。 |
![]() | ParsingApplied | セルの値が正常に解析されたかどうかを示す値を取得または設定します。 |
![]() | RowIndex | 解析を必要とするセルの行インデックスを取得します。 |
![]() | Value | ConvertEventArgs の値を取得または設定します。(ConvertEventArgs から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

関連項目
DataGridViewCellParsingEventArgs クラスSystem.Windows.Forms 名前空間
DataGridView クラス
DataGridView.CellParsing イベント
DataGridView.OnCellParsing
DataGridView.CellFormatting イベント
DataGridView.EditMode プロパティ
DataGridViewCell.ValueType プロパティ
DataGridViewCell.InheritedStyle プロパティ
DataGridViewCell.ParseFormattedValue
DataGridViewCellParsingEventHandler
ConvertEventArgs.Value プロパティ
InheritedCellStyle
ParsingApplied
DataGridViewCellStyle
DataGridViewCellStyle.NullValue
DataGridViewCellStyle.Format
DataGridViewCellStyle.FormatProvider
Weblioに収録されているすべての辞書からDataGridViewCellParsingEventArgsを検索する場合は、下記のリンクをクリックしてください。

- DataGridViewCellParsingEventArgsのページへのリンク