Skip to main content

RepositoryItemLookUpEdit Class

Contains settings specific to a lookup editor.

Namespace: DevExpress.XtraEditors.Repository

Assembly: DevExpress.XtraEditors.v24.1.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

[RepositoryItemLookUpEditBase.LookupEditCustomBindingProperties("LookUpEdit")]
public class RepositoryItemLookUpEdit :
    RepositoryItemLookUpEditBase,
    IDataInfo

The following members return RepositoryItemLookUpEdit objects:

Remarks

The RepositoryItemLookUpEdit class contains settings specific to a LookUpEdit control. Use the Properties property to access this settings. Read the following topic for information about common lookup settings: Lookup Main Settings.

A repository item includes properties, methods, and events that define the lookup’s behavior and appearance. The container controls (for example, the Data Grid, Tree List, Vertical Grid) use repository items to create cell (in-place) editors.

Example - How to Bind Lookup to Data

The following example shows how to bind a lookup editor to data created at runtime:

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

public partial class Form1 : DevExpress.XtraEditors.XtraForm {
    public Form1() {
        InitializeComponent();
        // Binds the lookup to data.
        lookUpEdit1.Properties.DataSource = Employee.GetSampleData();
        // Sets the lookup's data fields.
        lookUpEdit1.Properties.DisplayMember = "FullName";
        lookUpEdit1.Properties.ValueMember = "ID";
        // Sets the lookup's value. Selects the first record.
        lookUpEdit1.EditValue = 0;
    }
}

public class Employee {
    public Employee(int iD, string firstName, string lastName) {
        ID = iD;
        FirstName = firstName;
        LastName = lastName;
    }
    public static List<Employee> GetSampleData() {
        return new List<Employee>() {
            new Employee(0, "Bart", "Arnaz"),
            new Employee(1, "Leah", "Simpson"),
            new Employee(2, "Arnold", "Schwartz"),
            new Employee(3, "William", "Zimmer"),
            new Employee(4, "Samantha", "Piper")
        };
    }
    // The 'ID' field must contain unique values.
    public int ID { get; private set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
    [Display(Order = -1)]
    public string FullName {
        get {
            return string.Format("{0} {1}", FirstName, LastName);
        }
    }
}

The image below shows the result.

WinForms Lookup Editor

See Also