Combobox with duplicate display member values.

2 posts, 0 answers
  1. Alistair Wardlaw
    Alistair Wardlaw avatar
    2 posts
    Member since:
    Oct 2009

    Posted 10 Jan 2010 Link to this post

    Currently using a RadComboBox which is databound from a linq query.

    The ValueMember is a unique ID and DisplayMember is a user entered field.

    If the user enters duplicate values for the "name" field, both will display in the combo box, however SelectedValue will always return the first matching name in the list - even if the underlying ID's are different.

    Is this by design or is it a bug?


  2. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 12 Jan 2010 Link to this post

    Hello Alistair Wardlaw,

    Thank you for writing.

    I am afraid that I could not reproduce the behavior you described.

    Here is the code snippet I am testing with:

    List<CustomObject> ds = new List<CustomO
     
    ds.Add(new CustomObject("1", 5));
    ds.Add(new CustomObject("1", 1));
     
    this.radListBox1.DisplayMember = "Name";
    this.radListBox1.ValueMember = "Value";
    this.radListBox1.DataSource = ds;

     

    There are two objects with identical display values ("1") but different values for ValueMember (5 and 1).

    Calling SelectedValue.ToString() always returns the correct result based on the selection.

    Please explain in more details how to reproduce the issue or send a sample application which demonstrates it if possible.

    I am looking forward to your reply.

    Greetings,
    Victor
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top