Rediger

Del via


DataGridColumnStyle.Commit(CurrencyManager, Int32) Method

Definition

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

protected public:
 abstract bool Commit(System::Windows::Forms::CurrencyManager ^ dataSource, int rowNum);
protected internal abstract bool Commit (System.Windows.Forms.CurrencyManager dataSource, int rowNum);
abstract member Commit : System.Windows.Forms.CurrencyManager * int -> bool
Protected Friend MustOverride Function Commit (dataSource As CurrencyManager, rowNum As Integer) As Boolean

Parameters

rowNum
Int32

The number of the row being edited.

Returns

true if the editing procedure committed successfully; otherwise, false.

Examples

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

Notes to Implementers

The Commit(CurrencyManager, Int32) 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(CurrencyManager, Int32) method when the DataGridColumnStyle receives a request to complete editing. If this is not possible without error, return false.

The Commit(CurrencyManager, Int32) method is called by the public method OnMouseDown(MouseEventArgs) of the DataGrid control. The method is also called by other private methods, for example, when the current row is changed.

Applies to

See also