Skip to main content
A newer version of this page is available. .

RepositoryItemLookUpEditBase.DataSource Property

Gets or sets the source of data displayed in the dropdown window.

Namespace: DevExpress.XtraEditors.Repository

Assembly: DevExpress.XtraEditors.v20.2.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

[DefaultValue(null)]
[DXCategory("Data")]
public object DataSource { get; set; }

Property Value

Type Default Description
Object *null*

The source of data displayed in the dropdown.

Remarks

Use the DataSource property to specify the source of rows to display in the dropdown. The data source can represent any object that implements the IList or IListSource interfaces. Thus you can bind a lookup editor to an array or a collection of class objects, DataView, DataTable objects, etc.

A lookup editor allows you to use unbound columns - columns that display custom data that does not exist in the data source. To populate unbound columns in a LookUpEdit control, use the LookUpEdit.GetNotInListValue (or RepositoryItemLookUpEdit.GetNotInListValue) event. For information on how to implement unbound columns in a View that is embedded into the GridLookUpEdit control, see the Unbound Columns topic.

Refer to the LookUpEdit topic for information on customizing a lookup editor.

Dictionary as a Data Source

If you use a Dictionary<TKey,TValue> as a data source for a lookup editor, the editor uses keys and values as follows:

  • the TKey values — as actual values. These values are assigned to the editor when a user selects an item in the drop-down box.
  • the TValue values — as string representations of the actual values. These strings are displayed in the edit box and drop-down window.

There is no need to specify the ValueMember and DisplayMember properties.

Note

The TKey and TValue parameters should be of the String type or a value type. For example, keys are integers and values are strings.

See the following topic for more information: Dictionary as a Data Source for a Lookup Editor.

Example

This example shows how to use an in-place LookUpEdit control (RepositoryItemLookUpEdit) to edit cells in a grid column.

The lookup editor is assigned to the CategoryID column. The editor displays category names in the edit box instead of category IDs (see the DisplayMember setting).

lookup-standardmode-example-result.gif

View Example

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace LookupEdit_StandardBinding {
    static class Program {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main() {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the DataSource property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also