Back to Devexpress

BaseView.UpdateCurrentRow() Method

windowsforms-devexpress-dot-xtragrid-dot-views-dot-base-dot-baseview-f275d5a5.md

latest5.1 KB
Original Source

BaseView.UpdateCurrentRow() Method

Validates the currently focused row’s value/data.

Namespace : DevExpress.XtraGrid.Views.Base

Assembly : DevExpress.XtraGrid.v25.2.dll

NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

csharp
public virtual bool UpdateCurrentRow()
vb
Public Overridable Function UpdateCurrentRow As Boolean

Returns

TypeDescription
Boolean

true if the row has been successfully updated; otherwise, false.

|

Remarks

As implemented in the BaseView class, the UpdateCurrentRow method does nothing and always returns true. It is overridden in the ColumnView class to raise the ColumnView.ValidateRow event so that you can manually specify whether row values are valid. Read the ColumnView.UpdateCurrentRow topic for more information.

Refer to the Modify and Validate Cell Values topic for information on how to check the validity of data entered by end-users into a row.

Note

Detail pattern Views do not contain data and they are never displayed within XtraGrid. So, the UpdateCurrentRow member must not be invoked for these Views. The UpdateCurrentRow member can only be used with Views that display real data within the Grid Control. Use the following methods to access these Views with which an end user interacts at runtime.

Example: Immediately update the View on cell value changes

Assume that the content or appearance settings of a View’s specific elements are dependent on cell values, and you want to update these elements immediately after a cell value is changed. For instance, you may want to calculate a custom summary or apply conditional formatting after a user changes a cell value.

To perform this task, ensure that an in-place editor (a RepositoryItem descendant) is assigned to a column. Then handle an in-place editor’s RepositoryItem.EditValueChanged event, and call a Data Grid View’s PostEditor and UpdateCurrentRow methods.

csharp
RepositoryItemTextEdit rItemTextEdit = new RepositoryItemTextEdit();
rItemTextEdit.EditValueChanged += RItemTextEdit_EditValueChanged;
gridControl1.RepositoryItems.Add(rItemTextEdit);
gridColumn1.ColumnEdit = rItemTextEdit;

private void RItemTextEdit_EditValueChanged(object sender, EventArgs e) {
    if(gridView1.PostEditor())
        gridView1.UpdateCurrentRow();
}
vb
Dim rItemTextEdit As New RepositoryItemTextEdit()
AddHandler rItemTextEdit.EditValueChanged, AddressOf RItemTextEdit_EditValueChanged
GridControl1.RepositoryItems.Add(rItemTextEdit)
GridColumn1.ColumnEdit = rItemTextEdit

Private Sub RItemTextEdit_EditValueChanged(sender As Object, e As EventArgs)
    If GridView1.PostEditor() Then
        GridView1.UpdateCurrentRow()
    End If
End Sub

See Also

UpdateCurrentRow()

Edit Data. Create Cell Editors. Validate User Input

BaseView Class

BaseView Members

DevExpress.XtraGrid.Views.Base Namespace