Skip to main content

Lookup Main Settings

  • 5 minutes to read

Lookup editors have much in common because they all derive from the LookUpEditBase class.

Common Settings

The following table lists the most popular settings:

Property

Description

EditValue

Gets or sets the lookup’s value.

lookUpEdit1.EditValue = 0;

DataSource

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

// Binds the lookup to data.
lookUpEdit1.Properties.DataSource = Employee.GetSampleData();

DisplayMember

Specifies the name of a data source field, whose values are visible to users. A value from this field is displayed in the lookup’s text box when a user selects a record.

ValueMember

Specifies the name of a data source field with unique/key values. A value from this data field is assigned to the lookup’s EditValue property when a user selects a record. Use this property in Standard Lookup Binding Mode.

// Sets the lookup's data fields.
lookUpEdit1.Properties.DisplayMember = "FullName";
lookUpEdit1.Properties.ValueMember = "ID";

Important

When a lookup editor is used to edit cell values in the Data Grid, the type of the ValueMember field must match the type of the field assigned to the grid’s lookup column (GridColumn.FieldName).

KeyMember

Specifies the name of a key field (or multiple key fields). Use this property in Advanced Lookup Binding Mode.

TextEditStyle ProcessNewValue

Specifies whether users can type in the lookup’s text box.

Set the TextEditStyle property to Standard to allow users to type in the text box. Handle the ProcessNewValue event to parse entered values and add new records to the lookup’s data source.

// Enables adding new values.
lookUpEdit1.Properties.TextEditStyle = TextEditStyles.Standard;
lookUpEdit1.ProcessNewValue += new ProcessNewValueEventHandler(
    this.lookUpEdit1_ProcessNewValue
);

private void lookUpEdit1_ProcessNewValue(object sender, ProcessNewValueEventArgs e) {
    if((string)e.DisplayValue == String.Empty) return;
    List<Task> dataSource = (sender as LookUpEdit).Properties.DataSource as List<Task>;
    dataSource.Add(new Task(dataSource.Count) { Caption = (string)e.DisplayValue});
    e.Handled = true;
}

BestFitMode

Specifies the “best-fit” mode for lookup columns in the dropdown window. This feature proportionally resizes all columns to fit cell contents.

NullText

Specifies a string that is displayed in the text box when the lookup’s value is null (for example, System.DBNull.Value).

AllowNullInput

If enabled, users can press Delete, Backspace, or Ctrl+Delete to reset the lookup’s value to null. The TextEditStyle property should be set to DisableTextEditor or HideTextEditor.

Columns

Use this property to access a collection of lookup columns.

PopulateColumns()

Creates lookup columns for all fields in the data source.

GetNotInListValue

Lookups can display columns that are not bound to data source fields. Handle the GetNotInListValue event to display unbound data in LookUpEdit.

PopupWidth

Gets or sets the width of the dropdown window (in pixels). Use the PopupWidthMode property to specify whether the dropdown’s default width matches the width of the lookup or dropdown content.

DropDownRows

Specifies the dropdown’s height (in rows). Use the DropDownItemHeight property to specify the height of a row (in pixels).

CascadingOwner

Gets or sets the lookup editor whose value determines the filter criteria applied to the popup data source of the current lookup editor.

CascadingMember

Gets or sets the name(s) of the foreign key field(s) by which the popup data source of the lookup editor is filtered. The field must be editable and accept new values (read-only fields are not supported).

ImmediatePopup

Enable this option to display the dropdown immediately after a user has typed a character in the text box.

Lookup Settings

Property

Description

EditValueType

Gets or sets whether to enable the multiple item selection and specifies how the EditValue property stores selected items.

// Enables the multiple item selection.
lookUpEdit1.Properties.EditValueType = LookUpEditValueType.ValueList;
// Defines the property that specifies the item's selected state.
lookUpEdit1.Properties.CheckBoxSelectorMember = "Selected";

Grid Lookup Settings

Property

Description

PopupViewType

Specifies the type of View (for example, Grid View, Bands View, Tile View) that displays data in the dropdown.

PopupFilterMode

Specifies whether the lookup uses the Contains or StartsWith operator to filter its dropdown items when a user types text in the edit box.

AcceptEditorTextAsNewValue

Specifies whether the lookup accepts a value entered by a user in the text box that is not present in the data source. Read the following topic for detailed information: ComboBox Mode.

Search Lookup Settings

Property

Description

PopupViewType

Specifies the type of View that displays data in the dropdown.

PopupFilterMode

Specifies whether the lookup uses the Contains or StartsWith operator to filter its dropdown items when a user types text in the edit box.

PopupFindMode

Specifies whether to start the search automatically after a short delay, or when the Find button is clicked or ENTER is pressed.

ShowAddNewButton

Specifies whether to display the ‘Add New’ button in the dropdown.

ShowClearButton

Specifies whether to display the ‘Clear’ button in the dropdown.

TreeList Lookup Settings

Property

Description

TreeList

Gets or sets the TreeList control.

AutoExpandAllNodes

Gets or sets whether to expand all nodes when the TreeList is being loaded.

AutoComplete

Enables the Auto-Complete feature.

PopupFilterMode

Gets or sets how records in the dropdown window are filtered when typing text within the edit box.