Selected in C#

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

    Posted 12 Jul 2010 Link to this post

    Hello,

    My RadComboBox display a list of language and I need to select one from C#.  This is my code :

    <telerik:RadComboBox x:Name="RadComboBoxLstLg" ItemsSource="{StaticResource languages}" DisplayMemberPath="Name" />

    And this is my class :

    public class AvailLanguage : List<Language>
    {
        public AvailLanguage()
        {
            this.Add(new Language() { Name="English", Code="en-US" });
            this.Add(new Language() { Name = "Français (Canada)", Code = "fr-CA" });
            this.Add(new Language() { Name = "Spanish", Code = "es-ES" });
        }
    }
    public class Language
    {
        public string Name { get; set; }
        public string Code { get; set; }
    }

    Someone can tell (when my XAML page is loaded) how I can display in my RadComboBox I specific language by example es-ES.
     


  2. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 13 Jul 2010 Link to this post

    Hello Louis,

    The easiest way to select an item is to use the SelectedIndex property of RadComboBox:
    RadComboBoxLstLg.SelectedIndex = 2;

    There are other properties that control the selection:
    http://www.telerik.com/help/silverlight/radcombobox-features-selection.html

    All of them are read/write so you could use any of them to select an item and to get the selected item.

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