Make selected item in the listbox always at the top.

When i call a function , select a item in the list .but i want that selected move to the top of the list automatically, instead of click the scroolbar.

Can I do this Thank you.

I found this link ,  but i cant control the event scrolling. :(

http://www.codeproject.com/cs/combobox/ScrollingListbox.asp

This is my code , when i click button, the scrollbar move to new value 48.But it not works !

private void button1_Click(object sender, System.EventArgs e)

{

this.scrollingListBox1_Scrolled(

this.scrollingListBox1,

new System.Windows.Forms.ScrollEventArgs(System.Windows.Forms.ScrollEventType.EndScroll,48)

);

}




Answer this question

Make selected item in the listbox always at the top.

  • zeeshan_ahmad

    Can't you do this by setting the ListBox's TopIndex property

  • AndresF

    Daniel B. wrote:
    Can't you do this by setting the ListBox's TopIndex property

    :)) , thats all I need you help me.I am new comer in C# language.

    Thank Daniel B.I hope you can help me in future , and I will mark your answer as a best one.



  • Make selected item in the listbox always at the top.