RepositoryItemLookUpEditBase.DataSource Property

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

Namespace: DevExpress.XtraEditors.Repository

Assembly: DevExpress.XtraEditors.v20.1.dll

Declaration

[DXCategory("Data")]
[DefaultValue(null)]
public object DataSource { get; set; }
<DXCategory("Data")>
<DefaultValue(Nothing)>
Public Property DataSource As Object

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.

Examples

This example shows how to use an in-place LookUpEdit control (RepositoryItemLookUpEdit) for editing cells in a grid column.The lookup editor in the example is used to edit the CategoryID field values from the Products list. However, instead of displaying category IDs, the editor will display corresponding category names in the edit box.The main properties used to set up the LookUpEdit control are:- DataSource - Specifies the lookup data source.- ValueMember - Specifies the field from the lookup data source whose values match the editor's edit value.- DisplayMember - Identifies the field from the lookup data source whose values match the editor's display text.

The following image shows the result.

lookup-standardmode-example-result.gif

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());
        }
    }
}
See Also