![]() ![]() ' is the item displayed at the top in the ListBox. ![]() ' Determine if the currently selected item in the ListBox ListBox1.TopIndex = listBox1.SelectedIndex įor (int x = (listBox1.SelectedIndex -1) x >= 0 x-) If (listBox1.TopIndex != listBox1.SelectedIndex) Remove all items before the top item in the ListBox.įor ( int x = (listBox1->SelectedIndex - 1) x >= 0 x- ) ListBox1->TopIndex = listBox1->SelectedIndex Make the currently selected item the top item in the ListBox. If ( listBox1->TopIndex != listBox1->SelectedIndex ) is the item displayed at the top in the ListBox. ![]() Determine if the currently selected item in the ListBox This example requires that a ListBox containing items is added to a form and that an item is currently selected in the ListBox. The code then removes all items before the currently selected item and clears all selections in the ListBox. The code first moves the currently selected item in the ListBox to the top of the list. The example further demonstrates how to remove items using the RemoveAt method of the .ObjectCollection class, and how to clear all item selection using the ClearSelected method. The following code example demonstrates how to use the SelectedIndex property with the TopIndex property to move the currently selected item to the top of the list of items in the display area of the ListBox. The SelectionMode property is set to None. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |