DataGridViewDataErrorContexts 列挙体
この列挙体には、メンバ値のビットごとの組み合わせを可能にする FlagsAttribute 属性が含まれています。
名前空間: System.Windows.Formsアセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

<FlagsAttribute> _ Public Enumeration DataGridViewDataErrorContexts


この列挙体のメンバをビットごとの OR 演算を使用して結合し、データ エラー発生時のデータ連結 DataGridView の状態を表すことができます。たとえば、ユーザーがセルに無効な値を入力し (日付を入力するセルに名前を入力するなど)、他のセルを選択すると、DataGridView は無効なセル値をコミットしようとします。コミットに失敗すると、DataGridView では DataError イベントが発生します。Context プロパティの値は Commit および CurrentCellChange になります。

この型の使用方法を次のコード例に示します。次の例は「方法 : Windows フォーム DataGridView コントロールでのデータ入力中に発生したエラーを処理する」で取り上げている例の一部です。
Private Sub dataGridView1_DataError(ByVal sender As Object, _ ByVal e As DataGridViewDataErrorEventArgs) _ Handles dataGridView1.DataError ' If the data source raises an exception when a cell value is ' commited, display an error message. If Not e.Exception Is Nothing AndAlso _ e.Context = DataGridViewDataErrorContexts.Commit Then MessageBox.Show("CustomerID value must be unique.") End If End Sub
private void dataGridView1_DataError(object sender, DataGridViewDataErrorEventArgs e) { // If the data source raises an exception when a cell value is // commited, display an error message. if (e.Exception != null && e.Context == DataGridViewDataErrorContexts.Commit) { MessageBox.Show("CustomerID value must be unique."); } }

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


System.Windows.Forms 名前空間
DataGridView クラス
DataGridView.DataError イベント
DataGridViewDataErrorEventArgs.Context
- DataGridViewDataErrorContexts 列挙体のページへのリンク