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
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Collapse]Data Grid
   [Expand]Getting Started
   [Expand]Binding to Data
   [Expand]Grid View
   [Expand]View Technology
   [Expand]Grouping
   [Expand]Sorting
   [Expand]Summaries
   [Expand]Data Editing
   [Expand]Filtering and Locating Rows
   [Expand]Focus and Selection Handling
   [Expand]Processing Rows
   [Expand]Formatting Cell Values
   [Expand]Master-Detail Relationships
   [Expand]Asynchronous Image Load
   [Expand]Export and Printing
   [Expand]Appearance and Conditional Formatting
   [Expand]Batch Modifications
   [Expand]Hit Information
   [Expand]Hints
   [Expand]Popup Menus
   [Expand]Saving and Restoring Layouts
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Collapse]Examples
    [Collapse]Data Binding
      Examples: Data Binding
      How to: Add an Unbound Column Storing Arbitrary Data
      How to: Bind a GridControl to a Database in Server Mode
      How to: Create and customize a custom GridLookUpEdit control
      How to: Create and Customize a GridLookUpEdit Control at Runtime
      How to: Filter a LookUp(ComboBox) Column Based on Another Column Value
      How to: Reload Data from the Bound Database in Server Mode
    [Expand]Data Editing
    [Expand]Data Presentation
    [Expand]Export and Printing
    [Expand]Filtering
    [Expand]Formatting
    [Expand]General Use
    [Expand]Layout View
    [Expand]Master-Detail
    [Expand]Miscellaneous
    [Expand]Navigation and Selection
    [Expand]Painting
    [Expand]Skins and Look and Feel
    [Expand]Sorting and Grouping
    [Expand]Summaries
   [Expand]End-User Capabilities
    Included Components
  [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]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]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

How to: Create and Customize a GridLookUpEdit Control at Runtime

The following example demonstrates how to create and customize a GridLookUpEdit control at runtime.

In the example, a lookup editor will be used to edit the values of the "ProductID" field in the "Order Details" table (NWind database). It must display a list of the available products in the dropdown, which are stored in the "Products" table in the NWind database. By selecting a row from the dropdown an end-user will change the current order's product. Also a data navigator will be created that will assist an end-user to navigate through the "Order Details" table.

To implement the required functionality the following key properties of the lookup editor must be set:

  • The editor's BaseEdit.EditValue property is bound to the "ProductID" field in the "Order Details" table via the DataBindings property.
  • The editor's RepositoryItemLookUpEditBase.DataSource property is set to a DataView object which contains rows from the "Products" table in the NWind database.
  • The editor's RepositoryItemLookUpEditBase.ValueMember property is set to the "ProductID" field in the "Products" table. This field's value must match the editor's edit value, and so the "ProductID" field in the "Order Details" table.
  • The editor's RepositoryItemLookUpEditBase.DisplayMember property is set to the "ProductName" field in the "Products" table. This identifies the field in the DataSource whose values match the editor's display text.
  • Two columns are created within the underlying View via the ColumnView.Columns property. These will display values from the "ProductID" and "ProductName" fields in the dropdown data source.

The result of the example is shown in the following image:

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