DataGridView.CancelRowEdit イベント
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Dim instance As DataGridView Dim handler As QuestionEventHandler AddHandler instance.CancelRowEdit, handler
public: event QuestionEventHandler^ CancelRowEdit { void add (QuestionEventHandler^ value); void remove (QuestionEventHandler^ value); }

DataGridView が仮想モードの場合、変更は既定でセル レベルのデータ キャッシュにコミットされます。行レベルのトランザクションを実装する場合、CancelRowEdit イベントを使用できます。

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; } }

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


DataGridView クラス
DataGridView メンバ
System.Windows.Forms 名前空間
その他の技術情報
DataGridView コントロール (Windows フォーム)
Weblioに収録されているすべての辞書からDataGridView.CancelRowEdit イベントを検索する場合は、下記のリンクをクリックしてください。

- DataGridView.CancelRowEdit イベントのページへのリンク