[Expand]General Information
[Collapse]WinForms Controls
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications, and Dialogs
  [Collapse]Editors and Simple Controls
   [Collapse]Simple Editors
    [Expand]Included Components
    [Expand]Editors Structure
    [Collapse]Editors Features
      Text Editing Overview
     [Expand]Input Mask
     [Expand]Format and Parse Editor Values
     [Expand]Editor Buttons
     [Expand]Dropdown Editors Overview
      Image Editing Menu
     [Collapse]Data Binding Overview
       Binding to Regular ADO.NET Sources
       Binding to XML Data
       Binding to Data Created at Runtime
     [Expand]Appearance Customization
     [Expand]Miscellaneous Features
    [Expand]Member Tables
   [Expand]Lookup Editors
   [Expand]Token Edit Control
   [Expand]Breadcrumb Edit Control
   [Expand]Range Control
   [Expand]Image Slider
    Camera Control
    Templated ListBox Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Map Control
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Sunburst Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Binding to Data Created at Runtime

Binding editors to data stored in a database or a file is not the only option. Data can also be created and supplied at runtime. This topic describes how to do this. To learn about other data binding methods, refer to the Data Binding Overview topic.

Expanded Supplying an Editor with Data Created at Runtime

This data binding mode requires that the data source is an object holding a list of "records". Each "record" is an object whose public properties represent record fields and property values are field values. In general, to supply your editor with data created at runtime, you will need to follow the steps below:

  • Declare a class whose instances will represent records. This class's public properties will be treated as fields.
  • Declare a class implementing the IList, ITypedList or IBindingList interface. This class will represent a list serving as the editor's data source. This list's elements must be record objects.

    Note: if you don't want to create your own list object, you can use any of the existing objects implementing these interfaces. For instance, a DataTable object can serve as the data source. Therefore, this step is optional.

  • Create a new list instance and fill it with records. Bind an editor to a field using the editor's DataBindings property.

Note: only data sources implementing the IBindingList interface support data change notifications. When using a data source that doesn't support this interface, you may need to update editors manually. This can be done using the BaseControl.Refresh method, for instance.

Expanded Example - Supplying an Editor with Data Created at Runtime

The code below creates a class whose instances will represent records. The class declares two public properties (ID and Name), so that you can bind editors to their data.

Once a record class has been declared, you can create a list of its instances. This list serves as the data source. To bind an editor to this list, use the editor's DataBindings property. For most editors, you need to map data source fields to the BaseEdit.EditValue property. The code below shows how to bind a text editor to the Name field.

Expanded See Also

Is this topic helpful?​​​​​​​