windowsforms-devexpress-dot-xtragrid-dot-views-dot-base-dot-baseview-5f081c39.md
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.v25.2.dll
NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation
public bool PostEditor()
Public Function PostEditor As Boolean
| Type | Description |
|---|---|
| Boolean |
true if the value has been successfully saved to the data source; otherwise, false.
|
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.
Tip
The following in-place editors can post their value to the bound data source immediately after the value changes:
Use the editor’s InplaceModeImmediatePostChanges property to control this behavior. The WindowsFormsSettings.InplaceEditorUpdateMode property allows you to control update behavior globally.
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();
}
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
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();
}
}
Private checkEdit As New RepositoryItemCheckEdit()
Private checkEdit.EditValueChanged += AddressOf repositoryItemCheckEdit_EditValueChanged
gridControl1.RepositoryItems.Add(checkEdit)
gridView1.Columns("Marked").ColumnEdit = checkEdit
Private Sub repositoryItemCheckEdit_EditValueChanged(ByVal sender As Object, ByVal e As EventArgs)
If gridView.PostEditor() Then
gridView.UpdateCurrentRow()
End If
End Sub
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.
winforms-filter-lookup-column-based-on-another-lookup-column/CS/DxSample/MainForm.cs#L31
private void CountryEditor_EditValueChanged(object sender, EventArgs e) {
this.GridView.PostEditor();
this.GridView.SetFocusedRowCellValue("CityCode", null);
winforms-grid-auto-add-new-row-after-editing-last-cell/CS/Form1.cs#L81
if (_View.IsNewItemRow(_View.FocusedRowHandle)) {
_View.PostEditor();
_View.UpdateCurrentRow();
winforms-grid-use-layoutview-as-master-view/CS/WindowsApplication3/MasterDetailHelper.cs#L142
void OnCloseUp(object sender, DevExpress.XtraEditors.Controls.CloseUpEventArgs e) {
DetailView.PostEditor();
detailView.UpdateCurrentRow();
winforms-grid-add-radio-group-column/CS/Helper/GridRadioGroupColumnHelper.cs#L103
{
_GridView.PostEditor();
}
winforms-grid-update-row-style-on-cell-value-change/CS/Form1.cs#L61
{
gridView1.PostEditor();
}
winforms-filter-lookup-column-based-on-another-lookup-column/VB/DxSample/MainForm.vb#L33
Private Sub CountryEditor_EditValueChanged(ByVal sender As Object, ByVal e As EventArgs) Handles CountryEditor.EditValueChanged
Me.GridView.PostEditor()
Me.GridView.SetFocusedRowCellValue("CityCode", Nothing)
winforms-grid-auto-add-new-row-after-editing-last-cell/VB/Form1.vb#L74
If _View.IsNewItemRow(_View.FocusedRowHandle) Then
_View.PostEditor()
_View.UpdateCurrentRow()
winforms-grid-use-layoutview-as-master-view/VB/WindowsApplication3/MasterDetailHelper.vb#L153
Private Sub OnCloseUp(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.Controls.CloseUpEventArgs)
DetailView.PostEditor()
detailView_Renamed.UpdateCurrentRow()
winforms-grid-add-radio-group-column/VB/Helper/GridRadioGroupColumnHelper.vb#L102
Private Sub RadioRepositoryItem_EditValueChanged(ByVal sender As Object, ByVal e As EventArgs)
_GridView.PostEditor()
End Sub
winforms-grid-update-row-style-on-cell-value-change/VB/Form1.vb#L57
Private Sub OnEditValueChanged(ByVal sender As Object, ByVal e As EventArgs)
gridView1.PostEditor()
End Sub
See Also