Populate by code

5 posts, 0 answers
  1. Louis Bouchard
    Louis Bouchard avatar
    94 posts
    Member since:
    Feb 2010

    Posted 10 Jun 2010 Link to this post

    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.
  2. Louis Bouchard
    Louis Bouchard avatar
    94 posts
    Member since:
    Feb 2010

    Posted 10 Jun 2010 Link to this post

    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.
  3. DevCraft banner
  4. Louis Bouchard
    Louis Bouchard avatar
    94 posts
    Member since:
    Feb 2010

    Posted 10 Jun 2010 Link to this post

    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.

     

  5. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 14 Jun 2010 Link to this post

    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.
  6. Louis Bouchard
    Louis Bouchard avatar
    94 posts
    Member since:
    Feb 2010

    Posted 14 Jun 2010 Link to this post

    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.
Back to Top
DevCraft banner