DataGridViewDataErrorEventArgsとは? わかりやすく解説

DataGridViewDataErrorEventArgs クラス

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

DataError イベントデータ提供します

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

Public Class DataGridViewDataErrorEventArgs
    Inherits DataGridViewCellCancelEventArgs
Dim instance As DataGridViewDataErrorEventArgs
public class DataGridViewDataErrorEventArgs
 : DataGridViewCellCancelEventArgs
public ref class DataGridViewDataErrorEventArgs
 : public DataGridViewCellCancelEventArgs
public class DataGridViewDataErrorEventArgs
 extends DataGridViewCellCancelEventArgs
public class DataGridViewDataErrorEventArgs
 extends DataGridViewCellCancelEventArgs
解説解説
使用例使用例

DataGridViewDataErrorEventArgs クラスにより得られ情報応答する方法次のコード例示します

Private Sub DataGridView1_DataError(ByVal
 sender As Object, _
ByVal e As DataGridViewDataErrorEventArgs)
 _
Handles DataGridView1.DataError

    MessageBox.Show("Error happened " _
        & e.Context.ToString())

    If (e.Context = DataGridViewDataErrorContexts.Commit) _
        Then
        MessageBox.Show("Commit error")
    End If
    If (e.Context = DataGridViewDataErrorContexts _
        .CurrentCellChange) Then
        MessageBox.Show("Cell change")
    End If
    If (e.Context = DataGridViewDataErrorContexts.Parsing) _
        Then
        MessageBox.Show("parsing error")
    End If
    If (e.Context = _
        DataGridViewDataErrorContexts.LeaveControl) Then
        MessageBox.Show("leave control error")
    End If

    If (TypeOf (e.Exception) Is
 ConstraintException) Then
        Dim view As DataGridView = CType(sender,
 DataGridView)
        view.Rows(e.RowIndex).ErrorText = "an error"
        view.Rows(e.RowIndex).Cells(e.ColumnIndex) _
            .ErrorText = "an error"

        e.ThrowException = False
    End If
End Sub
private void DataGridView1_DataError(object
 sender, DataGridViewDataErrorEventArgs anError)
{

    MessageBox.Show("Error happened " + anError.Context.ToString());

    if (anError.Context == DataGridViewDataErrorContexts.Commit)
    {
        MessageBox.Show("Commit error");
    }
    if (anError.Context == DataGridViewDataErrorContexts.CurrentCellChange)
    {
        MessageBox.Show("Cell change");
    }
    if (anError.Context == DataGridViewDataErrorContexts.Parsing)
    {
        MessageBox.Show("parsing error");
    }
    if (anError.Context == DataGridViewDataErrorContexts.LeaveControl)
    {
        MessageBox.Show("leave control error");
    }

    if ((anError.Exception) is ConstraintException)
    {
        DataGridView view = (DataGridView)sender;
        view.Rows[anError.RowIndex].ErrorText = "an error";
        view.Rows[anError.RowIndex].Cells[anError.ColumnIndex].ErrorText = "an
 error";

        anError.ThrowException = false;
    }
}
private:
    void DataGridView1_DataError(Object^ sender, DataGridViewDataErrorEventArgs^
 anError)
    {

        MessageBox::Show("Error happened " + anError->Context.ToString());

        if (anError->Context == DataGridViewDataErrorContexts::Commit)
        {
            MessageBox::Show("Commit error");
        }
        if (anError->Context == DataGridViewDataErrorContexts::CurrentCellChange)
        {
            MessageBox::Show("Cell change");
        }
        if (anError->Context == DataGridViewDataErrorContexts::Parsing)
        {
            MessageBox::Show("parsing error");
        }
        if (anError->Context == DataGridViewDataErrorContexts::LeaveControl)
        {
            MessageBox::Show("leave control error");
        }

        if (dynamic_cast<ConstraintException^>(anError->Exception)
 != nullptr)
        {
            DataGridView^ view = (DataGridView^)sender;
            view->Rows[anError->RowIndex]->ErrorText = "an error";
            view->Rows[anError->RowIndex]->Cells[anError->ColumnIndex]->ErrorText
 = "an error";

            anError->ThrowException = false;
        }
    }
継承階層継承階層
System.Object
   System.EventArgs
     System.ComponentModel.CancelEventArgs
       System.Windows.Forms.DataGridViewCellCancelEventArgs
        System.Windows.Forms.DataGridViewDataErrorEventArgs
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

DataGridViewDataErrorEventArgs コンストラクタ

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

DataGridViewDataErrorEventArgs クラス新しインスタンス初期化します。

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

Public Sub New ( _
    exception As Exception, _
    columnIndex As Integer, _
    rowIndex As Integer, _
    context As DataGridViewDataErrorContexts _
)
Dim exception As Exception
Dim columnIndex As Integer
Dim rowIndex As Integer
Dim context As DataGridViewDataErrorContexts

Dim instance As New DataGridViewDataErrorEventArgs(exception,
 columnIndex, rowIndex, context)
public DataGridViewDataErrorEventArgs (
    Exception exception,
    int columnIndex,
    int rowIndex,
    DataGridViewDataErrorContexts context
)
public:
DataGridViewDataErrorEventArgs (
    Exception^ exception, 
    int columnIndex, 
    int rowIndex, 
    DataGridViewDataErrorContexts context
)
public DataGridViewDataErrorEventArgs (
    Exception exception, 
    int columnIndex, 
    int rowIndex, 
    DataGridViewDataErrorContexts context
)
public function DataGridViewDataErrorEventArgs
 (
    exception : Exception, 
    columnIndex : int, 
    rowIndex : int, 
    context : DataGridViewDataErrorContexts
)

パラメータ

exception

発生した例外

columnIndex

DataError が発生したセルの列インデックス

rowIndex

DataError発生したセルの行インデックス

context

エラー発生したコンテキストを示す DataGridViewDataErrorContexts 値のビットごとの組み合わせ

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataGridViewDataErrorEventArgs クラス
DataGridViewDataErrorEventArgs メンバ
System.Windows.Forms 名前空間

DataGridViewDataErrorEventArgs プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ Cancel  イベントキャンセルするかどうかを示す値を取得または設定します。 ( CancelEventArgs から継承されます。)
パブリック プロパティ ColumnIndex  イベント発生したセルの列インデックス取得します。 ( DataGridViewCellCancelEventArgs から継承されます。)
パブリック プロパティ Context エラー発生したときの DataGridView の状態の詳細取得します
パブリック プロパティ Exception エラーを表す例外取得します
パブリック プロパティ RowIndex  イベント発生したセルの行インデックス取得します。 ( DataGridViewCellCancelEventArgs から継承されます。)
パブリック プロパティ ThrowException DataGridViewDataErrorEventHandler デリゲート終了した後に例外スローするかどうかを示す値を取得または設定します
参照参照

関連項目

DataGridViewDataErrorEventArgs クラス
System.Windows.Forms 名前空間

DataGridViewDataErrorEventArgs メソッド


DataGridViewDataErrorEventArgs メンバ

DataError イベントデータ提供します

DataGridViewDataErrorEventArgs データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド DataGridViewDataErrorEventArgs DataGridViewDataErrorEventArgs クラス新しインスタンス初期化します。
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ Cancel  イベントキャンセルするかどうかを示す値を取得または設定します。(CancelEventArgs から継承されます。)
パブリック プロパティ ColumnIndex  イベント発生したセルの列インデックス取得します。(DataGridViewCellCancelEventArgs から継承されます。)
パブリック プロパティ Context エラー発生したときの DataGridView の状態の詳細取得します
パブリック プロパティ Exception エラーを表す例外取得します
パブリック プロパティ RowIndex  イベント発生したセルの行インデックス取得します。(DataGridViewCellCancelEventArgs から継承されます。)
パブリック プロパティ ThrowException DataGridViewDataErrorEventHandler デリゲート終了した後に例外スローするかどうかを示す値を取得または設定します
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

DataGridViewDataErrorEventArgs クラス
System.Windows.Forms 名前空間



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「DataGridViewDataErrorEventArgs」の関連用語

DataGridViewDataErrorEventArgsのお隣キーワード
検索ランキング

   

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



DataGridViewDataErrorEventArgsのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS