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

How to make selection move to top of the list?

1 Answer 302 Views
ComboBox and ListBox (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Evan Richardson
Top achievements
Rank 1
Evan Richardson asked on 31 Aug 2009, 08:49 PM
Hey everyone, hope you can help with this request because I don't know how to quite word it correctly, but I'm going to try my best.

I'm wondering if there is a way to code the combo box so that when a user selectes a value...and the box closes again, If you reopen the box, the selected value is either at the top or bottom of the list?  

for example lets say your drop down contains the following:

1
2
3 Selected Value
.
.
.
.
20

And then you select 3.   The drop down will close with that value selected, and then if you click to drop down again, your list now looks like this:


3 Selected Value
4
5
6
7
8
.
.
.


Same in reverse, so like if 6 was selected, then it would look like this:

1
2
3
4
5
6 selected value.


I hope that kinda makes sense.

Thanks.

1 Answer, 1 is accepted

Sort by
0
Deyan
Telerik team
answered on 01 Sep 2009, 08:31 AM
Hi Evan,

You can try using the following approach:


private
 void radComboBox1_SelectedIndexChanged(object sender, EventArgs e) 
     RadItem selectedItem = this.radComboBox1.SelectedItem as RadItem; 
 
     if (selectedItem != null
     { 
         this.radComboBox1.Items.Remove(selectedItem); 
         this.radComboBox1.Items.Insert(this.radComboBox1.Items.Count, selectedItem); 
         this.radComboBox1.Text = selectedItem.Text; 
     } 

In the SelectedIndexChanged event you can easily insert the SelectedItem at the position you would like it to appear. However, you should also set the Text of RadComboBox so that it does not disappear after you first remove the SelectedItem from the collection in order to insert it at another position.

I hope this helps.

Greetings,
Deyan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
ComboBox and ListBox (obsolete as of Q2 2010)
Asked by
Evan Richardson
Top achievements
Rank 1
Answers by
Deyan
Telerik team
Share this question
or