dropped down items not visible

3 posts, 1 answers
  1. Happy
    Happy avatar
    65 posts
    Member since:
    Aug 2008

    Posted 18 Aug 2009 Link to this post

    I'm adding an enumeration to a combobox using the following code:

    comboBox.DisplayMemberPath =

    "Name";

     

     

    comboBox.SelectedValuePath =

    "Name";

     

     

     

    List<RadComboBoxItem> items = new List<RadComboBoxItem>();

     

     

     

    foreach (FieldInfo fInfo in enumType.GetFields(BindingFlags.Public | BindingFlags.Static))

     

     

    {

     

        //object value = fInfo.GetValue(null);

     

        

    RadComboBoxItem item = new RadComboBoxItem();

     

        item.Name = fInfo.Name;

        items.Add(item);

     

    }

    comboBox.ItemsSource = items;

    The values are getting into the combobox, I just can't see them! I drop it down, I see the right number of BLANK rows, if I click a different row, the correct enumeration is getting set into my business object, but I just can't see anything. The dropdown box is blank.

    Telerik 2009.2.812.1030

     

     

  2. Answer
    Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 19 Aug 2009 Link to this post

    Hi,

    Instead of setting the Name property of RadComboBox item you could use its Content property. This way the values will be displayed properly.

    I have a blog post about displaying enum values in RadComboBox, that demonstrates another approach. You could check it for more information:
    http://blogs.telerik.com/valerihristov/posts/09-06-12/binding_a_combobox_to_enum_values_with_radcontrols_for_silverlight.aspx

    Best wishes,
    Valeri Hristov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Happy
    Happy avatar
    65 posts
    Member since:
    Aug 2008

    Posted 19 Aug 2009 Link to this post

    I tried your suggestion and it worked. The values now display in the dropdown portion. However, the primary part of the box still doesn't show the selected value.

    I visited your blog link and tried that approach, appreviated for my case to:

    comboBox.DisplayMemberPath =

    "";

     

    comboBox.SelectedValuePath =

    "";

     

    comboBox.ItemsSource = enumType.GetFields(

    BindingFlags.Public | BindingFlags.Static).Select<FieldInfo, object>((FieldInfo x) => x.GetValue(enumType));

    and that solves everything! The selected enum is appearing and the dropdown is showing all the values.

    Thanks!

     

Back to Top