DataGridView.CancelRowEdit イベントとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DataGridView.CancelRowEdit イベントの意味・解説 

DataGridView.CancelRowEdit イベント

メモ : このイベントは、.NET Framework version 2.0新しく追加されたものです。

DataGridView コントロールの VirtualMode プロパティtrue で、行の編集キャンセルした場合発生します

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

Public Event CancelRowEdit As
 QuestionEventHandler
Dim instance As DataGridView
Dim handler As QuestionEventHandler

AddHandler instance.CancelRowEdit, handler
public event QuestionEventHandler CancelRowEdit
public:
event QuestionEventHandler^ CancelRowEdit {
    void add (QuestionEventHandler^ value);
    void remove (QuestionEventHandler^ value);
}
/** @event */
public void add_CancelRowEdit (QuestionEventHandler
 value)

/** @event */
public void remove_CancelRowEdit (QuestionEventHandler
 value)
JScript では、イベント使用できますが、新規に宣言することはできません。
解説解説
使用例使用例

DataGridView コントロールのこのイベント仮想モード処理する方法次のコード例示しますコントロール編集モード場合rowInEdit 変数は、編集される行のインデックス保持しcustomerInEdit 変数は、その行に対応する Customer オブジェクトへの参照保持しますユーザー編集モードキャンセルすると、このオブジェクト破棄できます。ただし、ユーザー編集した行が新しレコードの行の場合、古い Customer オブジェクト破棄されユーザー編集再開できるように新しオブジェクト置換されます。次の例は「チュートリアル : Windows フォーム DataGridView コントロールでの仮想モード実装」で取り上げている例の一部です。

Private Sub dataGridView1_CancelRowEdit(ByVal
 sender As Object, _
    ByVal e As System.Windows.Forms.QuestionEventArgs)
 _
    Handles dataGridView1.CancelRowEdit

    If Me.rowInEdit = Me.dataGridView1.Rows.Count
 - 2 AndAlso _
        Me.rowInEdit = Me.customers.Count Then

        ' If the user has canceled the edit of a newly created row,
 
        ' replace the corresponding Customer object with a new, empty
 one.
        Me.customerInEdit = New Customer()

    Else

        ' If the user has canceled the edit of an existing row, 
        ' release the corresponding Customer object.
        Me.customerInEdit = Nothing
        Me.rowInEdit = -1

    End If

End Sub
private void dataGridView1_CancelRowEdit(object
 sender,
    System.Windows.Forms.QuestionEventArgs e)
{
    if (this.rowInEdit == this.dataGridView1.Rows.Count
 - 2 &&
        this.rowInEdit == this.customers.Count)
    {
        // If the user has canceled the edit of a newly created row,
 
        // replace the corresponding Customer object with a new, empty
 one.
        this.customerInEdit = new Customer();
    }
    else
    {
        // If the user has canceled the edit of an existing row, 
        // release the corresponding Customer object.
        this.customerInEdit = null;
        this.rowInEdit = -1;
    }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からDataGridView.CancelRowEdit イベントを検索した結果を表示しています。
Weblioに収録されているすべての辞書からDataGridView.CancelRowEdit イベントを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からDataGridView.CancelRowEdit イベント を検索

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

辞書ショートカット

すべての辞書の索引

「DataGridView.CancelRowEdit イベント」の関連用語

DataGridView.CancelRowEdit イベントのお隣キーワード
検索ランキング

   

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



DataGridView.CancelRowEdit イベントのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS