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

RepositoryItemLookUpEditBase.DisplayMember Property

Gets or sets the field whose values are displayed in the edit box.

Namespace: DevExpress.XtraEditors.Repository

Assembly: DevExpress.XtraEditors.v19.1.dll

Declaration

[DXCategory("Data")]
[DefaultValue("")]
public virtual string DisplayMember { get; set; }

Property Value

Type Default Description
String String.Empty

The string identifying the field whose values are displayed in the edit box.

Remarks

Use the DisplayMember property to specify the field whose values are displayed in the edit box. The value to display is obtained from the currently selected row in the dropdown list.

DisplayMember can represent a field from the data source specified by the RepositoryItemLookUpEditBase.DataSource property. In this case, the editor retrieves the value of this field from the data source for the row currently selected and displays it in the edit box.

For LookUpEdit controls, DisplayMember can also specify a field name that does not exist in the data source. Values for such fields should be retrieved manually by handling the RepositoryItemLookUpEdit.GetNotInListValue event.

Note

The ValueMember and DisplayMember properties must refer to columns that contain unique values. If the data source does not contain these columns, you can add an unbound column to a look up editor and populate this column with unique values by handling the LookUpEdit.GetNotInListValue event. This approach is only applicable for LookUpEdit controls.

Note

If the lookup editor’s edit value is bound to a field in a data source, this field’s type must match the type of the ValueMember field.

Note

The case of the strings assigned to the ValueMember and DisplayMember properties must exactly match the case of the names of the columns in the underlying data source.

Refer to the LookUpEdit topic for more information on setting up the lookup editor.

Example

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

The following code snippets (auto-collected from DevExpress Examples) contain references to the DisplayMember 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