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: Filter a LookUp(ComboBox) Column Based on Another Column Value

This example shows how to manually filter a lookup editor's popup data source based on the value of another lookup editor. The solution described is applicable to both standalone and in-place editors. However, for standalone editors you can use the automatic filtration feature instead, covered in the Cascading Lookups topic.

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E898.

Assume that a Data Grid contains two columns that should allow an end-user to select countries and cities from dropdown lists. When a certain country is selected in the first column, the second column's dropdown list should only provide cities from the selected country. To display the only appropriate values, the second column's values should be filtered based on the first column's value.

This task can be easily implemented if the second column's in-place editor is a look-up editor (LookUpEditBase descendant).

Handle the ColumnView.ShownEditor event, which fires after an in-place editor has been activated in any grid cell. Use this event to filter the list of items to be displayed in the look-up editor's dropdown and assign this list to the editor's RepositoryItemLookUpEditBase.DataSource property.

Expanded See Also

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