This is a migrated thread and some comments may be shown as answers.

dropped down items not visible

2 Answers 143 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Happy
Top achievements
Rank 1
Happy asked on 18 Aug 2009, 09:31 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Valeri Hristov
Telerik team
answered on 19 Aug 2009, 07:10 AM
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.
0
Happy
Top achievements
Rank 1
answered on 19 Aug 2009, 01:43 PM
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!

 

Tags
ComboBox
Asked by
Happy
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Happy
Top achievements
Rank 1
Share this question
or