Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [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
    Templated ListBox Items
   [Collapse]Simple Editors
    [Expand]Included Components
    [Expand]Editors Structure
    [Collapse]Editors Features
      Text Editing Overview
     [Expand]Mask Editors Overview
     [Expand]Formatting and Parsing Values
     [Expand]Editor Buttons Overview
     [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]Examples
   [Expand]Lookup Editors
   [Expand]Token Edit Control
   [Expand]Breadcrumb Edit Control
   [Expand]Range Control
   [Expand]Image Slider
    Camera Control
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap 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]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

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 will serve as the data source. After the data source has been created, you can bind an editor to its fields using the editor's DataBindings property. The code below shows how to bind a text editor to the Name field.

Expanded See Also

How would you rate this topic?​​​​​​​