locked
Rearrangig items in Listbox RRS feed

  • Question

  • I've ListBox x:name "List" , it contains many list items, but I want to rearrange the items Alphabetically, any help please ?!

    I am Using WPF(XAML) and C#

    Sunday, September 20, 2015 4:28 PM

Answers

  • Hi ,

    You can use sort method.

    ArrayList q = new ArrayList(); 
    foreach (object o in listBox4.Items) 
            q.Add(o);
    } 
    q.Sort(); 
    listBox5.Items.Clear();
    foreach(object o in q){
        listBox5.Items.Add(o); 
    }
    
    
    Similar:
    Sorting a WPF ListBox Items

    Thanks, SMSVikasK

    • Proposed as answer by Wizend Wednesday, September 23, 2015 9:59 AM
    • Marked as answer by Kristin Xie Monday, September 28, 2015 9:56 AM
    Sunday, September 20, 2015 4:49 PM