Ticket T200834
Visible to All Users

DisplayMember for ComboBoxEdit to display concatenate fields

created 10 years ago

Hi there,

I have a list of items of an entity framwork - current_data_list

And the following codes:

Visual Basic
data_combo_box_edit.ItemsSource = current_data_list data_combo_box_edit.DisplayMember = "LABEL" data_combo_box_edit.SelectedIndex = 0

This works great, but now I need to display more details in the DisplayMember e.g. LABEL and DESCRIPTION

I have tried doing

C#
data_combo_box_edit.DisplayMember = "LABEL" & "SHORT_DESCRIPTION"

but it just display blank labels.

Can I know what would be the beat way to achieve what I need? I would prefer to stick to codes than to use the XAML.

Answers approved by DevExpress Support

created 10 years ago (modified 10 years ago)

Hello Willson,

ComboBoxEdit's DisplayMember is designed to be used only for one property at the data source level. In case you need to display two or more property values in ComboBoxEdit items, you can define the corresponding DataTemplate and use it in the ComboBoxEdit.ItemTemplate property. To be able to see the same item presentation for the selected item in ComboBoxEdit, set the ComboBoxEdit.ApplyItemTemplateToSelectedItem property to True. I've created a simple sample to illustrate the main idea of the approach. Please refer to the attachment. I hope this will help.

Thanks,
Andrey

    Show previous comments (4)
    Andrey Marten (DevExpress Support) 7 years ago

      Hello,

      I've created a separate ticket on your behalf (T574847: ComboBoxEdit in GridControl - How to show values from different properties in DisplayMember). It has been placed in our processing queue and will be answered shortly.

      Thanks,
      Andrey

        If the IsTextEditable="false" is removed from the ComboBoxEdit, then after the closure of the dropdown, the objects ToString() is shown for the selected value (instead of the formatted text). Why that?

        Dima (DevExpress Support) 4 years ago

          Hello,

          This behavior is expected. The ApplyItemTemplateToSelectedItem option is in effect only when editing is disabled. In this scenario, you can use the EditTemplate property instead.

          Let me know if this helps.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.