RepositoryItemLookUpEdit.Columns Property

Provides access to the collection of columns displayed in the dropdown window.

Namespace: DevExpress.XtraEditors.Repository

Assembly: DevExpress.XtraEditors.v20.1.dll

Declaration

[DXCategory("Data")]
public LookUpColumnInfoCollection Columns { get; }
<DXCategory("Data")>
Public ReadOnly Property Columns As LookUpColumnInfoCollection

Property Value

Type Description
LookUpColumnInfoCollection

A LookUpColumnInfoCollection object specifying the columns displayed in the dropdown.

Remarks

Use the Columns property to add, remove and modify columns displayed in the popup window. Set the column's LookUpColumnInfo.FieldName property to bind this column to a data source field (see RepositoryItemLookUpEditBase.DataSource). If no field with such a name was found, the column is treated as "unbound" and you need to handle the RepositoryItemLookUpEdit.GetNotInListValue event to supply this column with data.

If you manually add LookUpEdit columns before the editor is initialized, it will not retrieve columns from a data source and only show your manually added columns. To show both custom columns and those retrieved from a data source, call the RepositoryItemLookUpEdit.PopulateColumns method. You may also need to call the RepositoryItemLookUpEdit.ForceInitialize method to ensure the editor is fully initialized before you start any customizations.

// Form.Load event (recommended)
private void Form1_Load(object sender, EventArgs e) {
    //. . .
    lookUpEdit1.Properties.PopulateColumns();
    lookUpEdit1.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("Code", "Added in code", 100));
}


// form constructor
public Form1() {
    InitializeComponent();
    //. . .
    lookUpEdit1.Properties.ForceInitialize();
    lookUpEdit1.Properties.PopulateColumns();
    lookUpEdit1.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("Code", "Added in code", 100));
}

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