I do not have the Sorted property in a ListBox element

0

As the question says, I'm working on ASP.NET . I have a listbox and when I enter the properties I do not get Sorted . I have visual 2017, did something similar happen to someone? Greetings and thanks.

    
asked by Excedd 15.08.2018 в 19:29
source

2 answers

0

Sorted is own from ListBox of Windows.forms

link

You must include System.Windows.Forms

using System.Windows.Forms;

WinForms Sorted : link

On the other hand, if you use the ListBox of System.Web.UI, you will not be able to access it.

System.Web.UI ListBox: link

    
answered by 15.08.2018 в 19:35
0

If someone serves, I could order the listbox with this code finally:

System.Collections.SortedList sorted = new SortedList();

foreach (ListItem ll in ListBox1.Items)
{
    sorted.Add(ll.Text, ll.Value);
}

ListBox1.Items.Clear();

foreach (String key in sorted.Keys)
{
    ListBox1.Items.Add(new ListItem(key, sorted[key].ToString()));
}
    
answered by 17.08.2018 в 17:09