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


DataGridView.CellValidating イベントを使用すると、新しい値が有効でない場合に、現在のセルに対する変更をキャンセルできます。現在の値を確認するには、FormattedValue プロパティを使用します。現在のセルの状態を確認するには、RowIndex プロパティと ColumnIndex プロパティを使用して、DataGridView.Rows コレクションを通じてセルにアクセスします。変更をキャンセルするには、Cancel プロパティを true に設定します。
このイベントがデータ バインド モードでキャンセルされた場合、新しい値は基になるデータ ソースにはプッシュされません。このイベントが仮想モードでキャンセルされた場合、DataGridView.CellValuePushed イベントは発生しません。

CellValidating イベントを処理して、ユーザーが正の整数だけを入力するようにするコード例を次に示します。この例は VirtualMode のリファレンス トピックで取り上げている例の一部分です。
Private Sub dataGridView1_CellValidating(ByVal sender As Object, _ ByVal e _ As DataGridViewCellValidatingEventArgs) _ Handles dataGridView1.CellValidating Me.dataGridView1.Rows(e.RowIndex).ErrorText = "" Dim newInteger As Integer ' Don't try to validate the 'new row' until finished ' editing since there ' is not any point in validating its initial value. If dataGridView1.Rows(e.RowIndex).IsNewRow Then Return If Not Integer.TryParse(e.FormattedValue.ToString(), newInteger) _ OrElse newInteger < 0 Then e.Cancel = True Me.dataGridView1.Rows(e.RowIndex).ErrorText = "the value must be a non-negative integer" End If End Sub
private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { dataGridView1.Rows[e.RowIndex].ErrorText = ""; int newInteger; // Don't try to validate the 'new row' until finished // editing since there // is not any point in validating its initial value. if (dataGridView1.Rows[e.RowIndex].IsNewRow) { return; } if (!int.TryParse(e.FormattedValue.ToString() , out newInteger) || newInteger < 0) { e.Cancel = true; dataGridView1.Rows[e.RowIndex].ErrorText = "the value must be a non-negative integer"; } }
void VirtualConnector::dataGridView1_CellValidating (Object^ sender, DataGridViewCellValidatingEventArgs^ e) { int newInteger; // Don't try to validate the 'new row' until finished // editing since there // is not any point in validating its initial value. if (dataGridView1->Rows[e->RowIndex]->IsNewRow) { return; } if (!Int32::TryParse(e->FormattedValue->ToString(), newInteger) || (newInteger < 0)) { e->Cancel = true; } }
private void dataGridView1_CellValidating(Object sender, DataGridViewCellValidatingEventArgs e) { int newInteger = 0; // Don't try to validate the 'new row' until finished // editing since there // is not any point in validating its initial value. if (dataGridView1.get_Rows().get_Item( e.get_RowIndex()).get_IsNewRow()) { return; } if (!(Int32.TryParse(e.get_FormattedValue().ToString(), newInteger)) || newInteger < 0) { e.set_Cancel(true); } } //dataGridView1_CellValidating

System.EventArgs
System.ComponentModel.CancelEventArgs
System.Windows.Forms.DataGridViewCellValidatingEventArgs


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


DataGridViewCellValidatingEventArgs メンバ
System.Windows.Forms 名前空間
DataGridView クラス
DataGridView.CellValidating イベント
DataGridView.CellValidated イベント
DataGridView.CellValuePushed イベント
DataGridView.OnCellValidating
DataGridViewCell クラス
DataGridViewCellValidatingEventHandler
FormattedValue
RowIndex
ColumnIndex
CancelEventArgs.Cancel
DataGridViewCellValidatingEventArgs プロパティ

名前 | 説明 | |
---|---|---|
![]() | Cancel | イベントをキャンセルするかどうかを示す値を取得または設定します。 ( CancelEventArgs から継承されます。) |
![]() | ColumnIndex | 検証する必要のあるセルの列インデックスを取得します。 |
![]() | FormattedValue | 検証する必要のあるセルの書式指定済みの内容を取得します。 |
![]() | RowIndex | 検証する必要のあるセルの行インデックスを取得します。 |

関連項目
DataGridViewCellValidatingEventArgs クラスSystem.Windows.Forms 名前空間
DataGridView クラス
DataGridView.CellValidating イベント
DataGridView.CellValidated イベント
DataGridView.CellValuePushed イベント
DataGridView.OnCellValidating
DataGridViewCell クラス
DataGridViewCellValidatingEventHandler
FormattedValue
RowIndex
ColumnIndex
CancelEventArgs.Cancel
DataGridViewCellValidatingEventArgs メソッド

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

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

関連項目
DataGridViewCellValidatingEventArgs クラスSystem.Windows.Forms 名前空間
DataGridView クラス
DataGridView.CellValidating イベント
DataGridView.CellValidated イベント
DataGridView.CellValuePushed イベント
DataGridView.OnCellValidating
DataGridViewCell クラス
DataGridViewCellValidatingEventHandler
FormattedValue
RowIndex
ColumnIndex
CancelEventArgs.Cancel
DataGridViewCellValidatingEventArgs メンバ
DataGridView コントロールの CellValidating イベントのデータを提供します。
DataGridViewCellValidatingEventArgs データ型で公開されるメンバを以下の表に示します。

名前 | 説明 | |
---|---|---|
![]() | Cancel | イベントをキャンセルするかどうかを示す値を取得または設定します。(CancelEventArgs から継承されます。) |
![]() | ColumnIndex | 検証する必要のあるセルの列インデックスを取得します。 |
![]() | FormattedValue | 検証する必要のあるセルの書式指定済みの内容を取得します。 |
![]() | RowIndex | 検証する必要のあるセルの行インデックスを取得します。 |

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

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

関連項目
DataGridViewCellValidatingEventArgs クラスSystem.Windows.Forms 名前空間
DataGridView クラス
DataGridView.CellValidating イベント
DataGridView.CellValidated イベント
DataGridView.CellValuePushed イベント
DataGridView.OnCellValidating
DataGridViewCell クラス
DataGridViewCellValidatingEventHandler
FormattedValue
RowIndex
ColumnIndex
CancelEventArgs.Cancel
Weblioに収録されているすべての辞書からDataGridViewCellValidatingEventArgsを検索する場合は、下記のリンクをクリックしてください。

- DataGridViewCellValidatingEventArgsのページへのリンク