Export (0) Print
Expand All
Expand Minimize

DataGridView.RowDirtyStateNeeded Event

Occurs when the VirtualMode property of the DataGridView control is true and the DataGridView needs to determine whether the current row has uncommitted changes.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

'Declaration
Public Event RowDirtyStateNeeded As QuestionEventHandler

By default, this event sets the QuestionEventArgs.Response property to true if any cells in the current row have been modified. This causes the CancelRowEdit event to occur when the user reverts edits to a row. Users can revert edits to a row by pressing ESC twice when a cell is in edit mode or once outside of edit mode. This event can be used for customizing commit scope in virtual mode by setting the QuestionEventArgs.Response property to the correct value depending on the chosen commit scope.

For more information about handling events, see Consuming Events.

The following code example demonstrates how to handle this event to provide cell-level commit scope, meaning that the user can revert changes to the current cell only. In cell-level commit scope, the row is treated as having uncommitted changes only when the current cell has uncommitted changes, rather than when any cell in the row has uncommitted changes. This example is part of a larger example available in Walkthrough: Implementing Virtual Mode in the Windows Forms DataGridView Control.


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

    If Not rowScopeCommit Then

        ' In cell-level commit scope, indicate whether the value
        ' of the current cell has been modified.
        e.Response = Me.dataGridView1.IsCurrentCellDirty

    End If

End Sub


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2014 Microsoft