Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to: Bind a Standalone Editor in Code

To bind a standalone editor in code, you need to add a Binding object to the control’s DataBindings collection. The FormattingEnabled property must be set to true.

The following example shows how to bind a DateEdit control to a nullable property of an Entity business object.

// An Entity object.
Entity _entity = new Entity();
// Bind the editor to the Entity.NullableDateTime property. 
// Set the Binding.FormattingEnabled property to true.
dateEdit1.DataBindings.Add("EditValue", _entity, "NullableDateTime", true);

public class Entity {
    public Entity() { }

    private DateTime? _nullableDateTime = new DateTime(2001, 1, 1);

    public DateTime? NullableDateTime {
        get { return _nullableDateTime; }
        set { _nullableDateTime = value; }
    }
}