Gets or sets a value indicating whether the items in the ListBox are sorted alphabetically.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Use the property to automatically sort strings alphabetically in a ListBox. As items are added to a sorted ListBox, the items are moved to the appropriate location in the sorted list. When adding items to a ListBox, it is more efficient to sort the items first and then add new items.
A ListBox with its set to true should not be bound to data using the DataSource property. To display sorted data in a bound ListBox, you should bind to a data source that supports sorting and have the data source provide the sorting.
The following code example demonstrates how to use the GetSelected method to determine which items in a ListBox are selected in order to select the items that are not selected and deselect the items that are selected. The example also demonstrates using the SelectionMode property to enable a ListBox to have more than one selected item and uses the property to demonstrate how to sort items in a ListBox automatically. This example requires that a ListBox, named listBox1, has been added to a form and that the InitializeMyListBox method defined in the example is called from the Load event of the form.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.