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

Changing the selected item

5 Answers 100 Views
DataBoundListBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tariq
Top achievements
Rank 2
Tariq asked on 12 Jul 2011, 03:12 PM
hi, i need to change the selected item in code. i used to do that using the selectedIndex
the items am using are objects from a class i made. 

5 Answers, 1 is accepted

Sort by
0
Deyan
Telerik team
answered on 12 Jul 2011, 03:15 PM
Hello Tareq,

You can use the SelectedItem property to change the selection in RadDataBoundListBox. You can set it to an object at a specified index within your source collection and this item will become selected in RadDataBoundListBox.

Greetings,
Deyan
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Tariq
Top achievements
Rank 2
answered on 12 Jul 2011, 03:44 PM
its not working, or maybe am doing something wrong, heres my code:

private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
    XDocument loadedData = XDocument.Load("EngToAra.xml");
    var data = from query in loadedData.Descendants("word")
               select new Ara
               {
                   Arabic = (string)query.Element("arabic"),
                   English = (string) query.Element("english")
               };
    List<Ara> d = data.ToList<Ara>();
    ara = d;
    radListBox.ItemsSource = data;
}

this is my Page Load, and this a button even to select the data:
private void button1_Click(object sender, RoutedEventArgs e)
{
    radListBox.SelectedItem = ara[100];
}
0
Deyan
Telerik team
answered on 12 Jul 2011, 03:51 PM
Hello Tareq,

Thanks for writing.

Based on what I am seeing in your code snippet  I think that the selection should work as expected. Could you please prepare a small demo project that reproduces the issue and send it to us in a new support ticket so that we can see what actually goes wrong and thus be able to further assist you.

Thanks for your time.

Greetings,
Deyan
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Tariq
Top achievements
Rank 2
answered on 12 Jul 2011, 04:06 PM
where should i send it to? and whats support ticket?



EDIT: never mind, i got it.
0
Tariq
Top achievements
Rank 2
answered on 12 Jul 2011, 06:31 PM
i got it, it was the assigning thingy in the load event, i should just assign the item source to the List instead of the var data.

thanks,

private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
    XDocument loadedData = XDocument.Load("EngToAra.xml");
    var data = from query in loadedData.Descendants("word")
               select new Ara
               {
                   Arabic = (string)query.Element("arabic"),
                   English = (string) query.Element("english")
               };
    List<Ara> d = data.ToList<Ara>();
    ara = d;
   // radListBox.ItemsSource = data;
     radListBox.ItemsSource = ara;
}
Tags
DataBoundListBox
Asked by
Tariq
Top achievements
Rank 2
Answers by
Deyan
Telerik team
Tariq
Top achievements
Rank 2
Share this question
or