[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
 [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 Regular ADO.NET Sources

In this tutorial you will bind editors of three different types to the same data source created beforehand.

Expanded Add Data Source

  1. Create a new WinForms application using the DevExpress Template Gallery, the "Blank Application" template.
  2. In Visual Studio, click "Project | Add New Data Source...".

  3. In this tutorial, a data source will be a sample "Northwind.mdf" database running on a local SQL Express Server. Choose "Database | Dataset" and click the "New Connection..." button.

  4. Select a server and a database.

  5. Select a required data table or view, then check data fields you need and click "Finish".

  6. Rebuild your project and make sure your data source is now visible in the VS Solution Explorer window.

Expanded Single-Value Editors

  1. Place two editors onto the form - TextEdit and CheckEdit.

  2. Select the TextEdit control and expand the "Data Bindings" section in the VS Properties window. Click the ellipsis button for the "(Advanced)" row.

  3. Expand the drop-down "Binding" list and locate your data source under the "Project Data Sources" node. Then, select a data field that should be bound to your editor (e.g., "ProductName").

    After this step you will have the DataSet, DataSource and TableAdapter components added automatically.

  4. Use the same data set to bind the second editor to the boolean "Discontinued" field.

  5. Run the application. Your editors now reflect values stored in the first data source row.

Expanded Lookups and other Bindable Multi-Value Editors

  1. Place a GridLookUpEdit control onto the form.

  2. Invoke the editor's smart tag and launch the Data Source Configuration Wizard by clicking "Data Source Wizard".

  3. Switch to the "ADO.NET Typed DataSet" wizard tab, select your existing data source and click "Next". Choose the "Binding via the BindingSource Component" option on the second wizard page.

  4. Select the data field that should correspond to the editor's display text (the "Display Member" selector) and the editor's edit value (the "Value Member" selector). Optionally, filter and/or sort your data as required.

  5. The editor is now bound to your data set.

  6. To remove and/or customize GridLookUpEdit columns, invoke the editor's smart tag and click "Design View". Switch to the "Columns" tab and click the "Retreive Fields" button to explicitly generate a column for each data field in the data source.

  7. You can now remove columns to hide unwanted data (e.g., the "ProductID" field) and utilize the property grid to customize the remaining columns. For instance, by using the GridColumn.ColumnEdit property, you can replace default check boxes with ToggleSwitch editors for the "Discontinued" column.

  8. Run the application to see the final result.

See also:

Binding Lookup Editors to Simple Data Types | How to: Create Lookup Editor and Bind It to Data Source

Expanded Multi-Value Editors without the DataSource Property

Unlike lookups, editors as well as ComboBox are not data-aware and provide no DataSource property. For such editors, you need to parse data rows and manually create items.

  • Add a standard DataSet component from the Visual Studio Toolbox. Select your existing data source when prompted.

  • Rebuild your project and add a table adapter from the toolbox.

  • Populate the data set by calling the adapter's Fill method as shown below.

  • Place a Token Edit Control onto the form.
  • Add tokens for each row in the data set. Note that tokens must have unique values to function properly.

  • Run the application to see the result.

Expanded See Also

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