DataGridColumnStyle.Commit Method

When overridden in a derived class, initiates a request to complete an editing procedure.

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

protected internal abstract bool Commit(
	CurrencyManager dataSource,
	int rowNum
)

Parameters

dataSource
Type: System.Windows.Forms.CurrencyManager

The CurrencyManager for the DataGridColumnStyle.

rowNum
Type: System.Int32

The number of the row being edited.

Return Value

Type: System.Boolean
true if the editing procedure committed successfully; otherwise, false.

Notes to Inheritors

The Commit method should be used by classes derived from the DataGridColumnStyle class to reset their editing state, for example, to concede the focus if the DataGridColumnStyle hosts an editing control. See the ConcedeFocus method.

Call the Commit method when the DataGridColumnStyle receives a request to complete editing. If this is not possible without error, return false.

The Commit method is called by the public method OnMouseDown of the System.Windows.Forms.DataGrid control. The method is also called by other private methods, for example, when the current row is changed.

The following code example shows a possible override of the Commit method. The code invokes the SetColumnValueAtRow method, and then sets a variable that allows other functions to determine whether the column is still in edit more. The code then calls the Invalidate method to redraw the control. Finally, the function returns true to indicate the change has been committed.

Protected Overrides Function Commit(dataSource As System.Windows.Forms.CurrencyManager, rowNum As Integer) As Boolean
    SetColumnValueAtRow(dataSource, rowNum, currentValue)
    isEditing = False
    Invalidate
    Commit = True 
End Function

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft