KB Article T685021
Visible to All Users

Why editors bound to XPCollection do not refresh their text automatically when a user modifies values

Consider a simple screen that contains a Lookup Editor to select a value and displays a selected record's details separately.

The editor is bound to the XPCollection component and the DataSourceUpdateMode option is set to OnPropertyChanged for the Lookup Editor to immediately update the UI if a user selects another value.

C#
EditorAssignedTo.DataBindings.Add("EditValue", TasksSource, "AssignedTo!Key", false, DataSourceUpdateMode.OnPropertyChanged);

Actually, the editor will not refresh itself instantly.

Cause
XPCollection and Base XPO Classes are designed to provide backward compatibility with legacy DataSet-based WinForms applications. These classes make migration to XPO easy. The behavior described above is caused by the IEditableObject interface implementation and copies the DataSet behavior. Once the editing operation started (the IEditableObject.BeginEdit method is called), XPCollection stops raising the ListChanged event for changes made through data bindings until the IEditableObject.EndEdit or IEditableObject.CancelEdit method is executed.

Solution
We suggest using a special component designed for WinForms data binding: XPBindingSource. For convenience, it is designed similarly as the standard BindingSource component. Use it to create data bindings in the visual designer and initialize the DataSource property at run time. Refer to the following example for details: How to Bind Data to WinForms Controls.

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.