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

Populate by code

4 Answers 52 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Louis Bouchard
Top achievements
Rank 1
Louis Bouchard asked on 10 Jun 2010, 06:34 PM
Hello,

I got a RadCombobox in a DataForm and I just want to populate it with 1, 2 ,3 and so on.  Where I can do it (event) and how (code).

Thank you.

4 Answers, 1 is accepted

Sort by
0
Louis Bouchard
Top achievements
Rank 1
answered on 10 Jun 2010, 07:58 PM
OK I find this to populate my ComboBox :

<telerikInput:RadComboBox Name="ComboBoxQty" SelectedValue="{Binding Quantity, Mode=TwoWay}" SelectedValuePath="Qty"  Width="100" Height="25" DisplayMemberPath="????" ItemsSource="????" >
   <telerikInput:RadComboBoxItem Content="1" />
   <telerikInput:RadComboBoxItem Content="2" />
   <telerikInput:RadComboBoxItem Content="3" />
</telerikInput:RadComboBox>

1) But what I have to do with the DisplayMemberPath?
2) Do I have to do something with the ItemsSource?

For now my DataForm is not updated when I select an item in my RadComboBox.
0
Louis Bouchard
Top achievements
Rank 1
answered on 10 Jun 2010, 11:19 PM
Ok now my DataForm is updated
 
I  got only 1 problem.

The Combobox update my field but when I save my DataForm the value selected disappear in the ComboBox (display nothing). 

 

 

 

 

<telerik:RadComboBox Name="ComboBoxQty" SelectedValue="{Binding Qty, Mode=TwoWay}" SelectedValuePath="Content" Width="100" Height="25">

 

 

 

<telerik:RadComboBoxItem Content="1" />

 

 

 

<telerik:RadComboBoxItem Content="2" />

 

 

 

<telerik:RadComboBoxItem Content="3" />

 

 

 

<telerik:RadComboBoxItem Content="4" />

 

 

 

<telerik:RadComboBoxItem Content="5" />

 

 

 

</telerik:RadComboBox>

 I try to set DisplayMemberPath with different value like "Content" but nothink work.

 

0
Valeri Hristov
Telerik team
answered on 14 Jun 2010, 09:23 AM
Hello Louis,

The Content property of RadComboBoxItem is of type Object and is not automatically converted to Integer (I suppose that the Qty property is integer), hence RadComboBox is comparing the string "1" to the integer 1 and cannot preselect its items. You could try addung a Converter (IValueConverter) on the SelectedValue Binding that will convert the strings to integers and vice versa.

Other option is to put integers instead of RadComboBoxItems inside RadComboBox (note there is no SelectedValuePath):
<telerik:RadComboBox Name="ComboBoxQty" SelectedValue="{Binding Qty, Mode=TwoWay}" Width="100" Height="25">
<system:Int32>1</system:Int32>
<system:Int32>2</system:Int32>
<system:Int32>3</system:Int32>
</telerik:RadComboBox>

where the system XML namespace is declared like this:
xmlns:system="clr-namespace:System;assembly=mscorlib"

Best wishes,
Valeri Hristov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Louis Bouchard
Top achievements
Rank 1
answered on 15 Jun 2010, 02:29 AM
Hello Valeri,

Thank you a lot.  It's really helps and it's the more important it's working.  And this link helps me to construct the Converter :

http://blogs.telerik.com/blogs/posts/09-04-29/using_ivalueconverter_to_format_values_in_radcontrols_for_silverlight.aspx


Bye for now and have nice day.
Tags
ComboBox
Asked by
Louis Bouchard
Top achievements
Rank 1
Answers by
Louis Bouchard
Top achievements
Rank 1
Valeri Hristov
Telerik team
Share this question
or