windowsforms-devexpress-dot-xtraeditors-dot-repository-dot-baserepositoryitemcheckedit.md
Gets or sets whether the in-place editor posts its value to the bound data source immediately after the value changes.
Namespace : DevExpress.XtraEditors.Repository
Assembly : DevExpress.XtraEditors.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
[Browsable(true)]
public override DefaultBoolean InplaceModeImmediatePostChanges { get; set; }
<Browsable(True)>
Public Overrides Property InplaceModeImmediatePostChanges As DefaultBoolean
| Type | Description |
|---|---|
| DefaultBoolean |
True to post the edit value to the bound data source immediately after the value changes; False to post the edit value after losing focus.
|
Available values:
| Name | Description | Return Value |
|---|---|---|
| True |
The value is true.
|
0
| | False |
The value is false.
|
1
| | Default |
The value is specified by a global option or a higher-level object.
|
2
|
Enable the InplaceModeImmediatePostChanges option to ensure that dependent functionality reacts immediately to user input (for example, conditional formatting, data summaries, event handlers that rely on bound field values, etc.).
If the InplaceModeImmediatePostChanges property is set to DefaultBoolean.True, the editor posts its value to the data source as soon as its value changes (without waiting for the cell to lose focus). This behavior is supported by in-place editors where input does not rely on text editing:
If the InplaceModeImmediatePostChanges property is set to DefaultBoolean.False, the editor posts its value after losing focus (for example, when the user focuses another grid cell).
Tip
Set the InplaceModeImmediatePostChanges property to DefaultBoolean.Default and use the WindowsFormsSettings.InplaceEditorUpdateMode property to control update behavior globally:
Immediate - Post the edit value immediately after the user modifies it.Postponed - Post the edit value when the cell loses focus.The following example:
Product objects.RepositoryItemCheckEdit that immediately posts changes to the grid’s data source.The following animation shows the result:
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Repository;
using DevExpress.XtraBars.Ribbon;
using DevExpress.Utils;
using System.Collections.Generic;
using System.Drawing;
using System.ComponentModel.DataAnnotations;
namespace DXApplication {
public partial class Form1 : RibbonForm {
public Form1() {
InitializeComponent();
// Bind the grid to data.
gridControl.DataSource = DataHelper.LoadProducts();
// Force the grid to initialize its structure and data binding.
gridControl.ForceInitialize();
// Create a new check edit repository item with immediate value posting enabled.
RepositoryItemCheckEdit riCheckEdit1 = new RepositoryItemCheckEdit(){
InplaceModeImmediatePostChanges = DefaultBoolean.True
};
// Add the repository item to the grid's collection.
gridControl.RepositoryItems.Add(riCheckEdit1);
// Assign the repository item to the "InStock" column.
gridView.Columns["InStock"].ColumnEdit = riCheckEdit1;
AppearanceObject valueRuleAppearance = new AppearanceObject() {
BackColor = Color.WhiteSmoke,
ForeColor = Color.Gray
};
// Create a formatting rule that targets "true" values in the "InStock" column.
FormatConditionRuleValue valueRule = new FormatConditionRuleValue()
{
Value1 = false, // Trigger formatting when the value is false.
Condition = FormatCondition.Equal, // Apply the rule when the value equals false.
};
// Assign appearance settings to the rule.
valueRule.Appearance.Assign(valueRuleAppearance);
// Create a format rule for the "InStock" column.
GridFormatRule inStockRule = new GridFormatRule(){
Rule = valueRule,
Column = gridView.Columns["InStock"],
ApplyToRow = true,
Enabled = true
};
// Add the formatting rule to the grid.
gridView.FormatRules.Add(inStockRule);
// Enable the Conditional Formatting menu item in the grid's context menu.
gridView.OptionsMenu.ShowConditionalFormattingItem = true;
// Create an unbound column to display notes based on a condition.
GridColumn notesColumn = new GridColumn() {
FieldName = "Notes",
Visible = true,
UnboundDataType = typeof(string),
UnboundExpression = "Iif([InStock], '', 'Not available in your region')",
};
gridView.Columns.Add(notesColumn);
}
}
public class Product {
public string Name { get; set; }
[DisplayFormat(DataFormatString = "c2")]
public double Price { get; set; }
public bool InStock { get; set; }
}
public class DataHelper {
public static List<Product> LoadProducts() {
return new List<Product> {
new Product { Name = "Product 1", Price = 10.0, InStock = true },
new Product { Name = "Product 2", Price = 20.0, InStock = false },
new Product { Name = "Product 3", Price = 30.0, InStock = true },
new Product { Name = "Product 4", Price = 40.0, InStock = false },
new Product { Name = "Product 5", Price = 50.0, InStock = true }
};
}
}
}
Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Columns
Imports DevExpress.XtraEditors
Imports DevExpress.XtraEditors.Repository
Imports DevExpress.XtraBars.Ribbon
Imports DevExpress.Utils
Imports System.Collections.Generic
Imports System.Drawing
Imports System.ComponentModel.DataAnnotations
Namespace DXApplication
Public Partial Class Form1
Inherits RibbonForm
Public Sub New()
InitializeComponent()
' Bind the grid to data.
gridControl.DataSource = DataHelper.LoadProducts()
' Force the grid to initialize its structure and data binding.
gridControl.ForceInitialize()
' Create a new check edit repository item with immediate value posting enabled.
Dim riCheckEdit1 As New RepositoryItemCheckEdit() With {
.InplaceModeImmediatePostChanges = DefaultBoolean.True
}
' Add the repository item to the grid's collection.
gridControl.RepositoryItems.Add(riCheckEdit1)
' Assign the repository item to the "InStock" column.
gridView.Columns("InStock").ColumnEdit = riCheckEdit1
Dim valueRuleAppearance As New AppearanceObject() With {
.BackColor = Color.WhiteSmoke,
.ForeColor = Color.Gray
}
' Create a formatting rule that targets "true" values in the "InStock" column.
Dim valueRule As New FormatConditionRuleValue() With {
.Value1 = False, ' Trigger formatting when the value is false.
.Condition = FormatCondition.Equal ' Apply the rule when the value equals false.
}
' Assign appearance settings to the rule.
valueRule.Appearance.Assign(valueRuleAppearance)
' Create a format rule for the "InStock" column.
Dim inStockRule As New GridFormatRule() With {
.Rule = valueRule,
.Column = gridView.Columns("InStock"),
.ApplyToRow = True,
.Enabled = True
}
' Add the formatting rule to the grid.
gridView.FormatRules.Add(inStockRule)
' Enable the Conditional Formatting menu item in the grid's context menu.
gridView.OptionsMenu.ShowConditionalFormattingItem = True
' Create an unbound column to display notes based on a condition.
Dim notesColumn As New GridColumn() With {
.FieldName = "Notes",
.Visible = True,
.UnboundDataType = GetType(String),
.UnboundExpression = "Iif([InStock], '', 'Not available in your region')"
}
gridView.Columns.Add(notesColumn)
End Sub
End Class
Public Class Product
Public Property Name As String
<DisplayFormat(DataFormatString := "c2")>
Public Property Price As Double
Public Property InStock As Boolean
End Class
Public Class DataHelper
Public Shared Function LoadProducts() As List(Of Product)
Return New List(Of Product) From {
New Product With {.Name = "Product 1", .Price = 10.0, .InStock = True},
New Product With {.Name = "Product 2", .Price = 20.0, .InStock = False},
New Product With {.Name = "Product 3", .Price = 30.0, .InStock = True},
New Product With {.Name = "Product 4", .Price = 40.0, .InStock = False},
New Product With {.Name = "Product 5", .Price = 50.0, .InStock = True}
}
End Function
End Class
End Namespace
See Also
Edit Data. Create Cell Editors. Validate User Input
BaseRepositoryItemCheckEdit Class