Skip to main content

BaseView.PostEditor() Method

Saves the modified cell value to the data source. If the GridOptionsView.RowAutoHeight setting is disabled, the currently active cell editor remains opened.

Namespace: DevExpress.XtraGrid.Views.Base

Assembly: DevExpress.XtraGrid.v24.1.dll

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

Declaration

public bool PostEditor()

Returns

Type Description
Boolean

true if the value has been successfully saved to the data source; otherwise, false.

Remarks

Note

Detail pattern Views do not contain data and they are never displayed within XtraGrid. So, the PostEditor member must not be invoked for these Views. The PostEditor 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.

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

Example: Immediately save a Boolean column’s check state to a data source

To save a Boolean column’s check state to a data source once a user toggles the check box, ensure that a check edit in-place editor (RepositoryItemCheckEdit) is assigned to a column. Then handle the RepositoryItem.EditValueChanged event to call the View’s PostEditor and UpdateCurrentRow methods.

RepositoryItemCheckEdit checkEdit = new RepositoryItemCheckEdit();
checkEdit.EditValueChanged += repositoryItemCheckEdit_EditValueChanged;
gridControl1.RepositoryItems.Add(checkEdit);
gridView1.Columns["Marked"].ColumnEdit = checkEdit;

private void repositoryItemCheckEdit_EditValueChanged(object sender, EventArgs e) {
    if(gridView.PostEditor()) {
        gridView.UpdateCurrentRow();
    }  
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the PostEditor() method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also