ListBoxes in C#


•ListBox stores several text items. It can interact with other controls, including Button controls. We use this control in Windows Forms.



 ListBox Properties

BorderStyle: Gets or sets the type of border that is drawn around the ListBox.
HorizontalScrollbar:  Gets or sets a value indicating whether a horizontal scroll bar is displayed in the control.
Items: Gets the items of the ListBox.
RightToLeft: Gets or sets a value indicating whether text displayed by the control is displayed from right to left.
ScrollAlwaysVisible:  Gets or sets a value indicating whether the vertical scroll bar is shown at all times.
SelectedIndex:  Gets or sets the zero-based index of the currently selected item in a ListBox.
Sorted: Gets or sets a value indicating whether the items in the ListBox are sorted alphabetically.
Text: Gets or searches for the text of the currently selected item in the ListBox
TopIndex  : Gets or sets the index of the first visible item in the ListBox.
SelectedItems:  Gets a collection containing the currently selected items in the ListBox.


Item Methods


Item.Add(): Can use to add Items to the end of the Listbox.

Item.Insert(): Can use for insert items into Listboxز

Item.Sorted(): Can use for sorted all items in the Listbox.

Item.Remove(): Can use to remove items from the Listboxز

Item.RemoveAt(): Can use to remove items by indexز

Item.Clear(): Can use to clear all items in the Listbox.

No comments:

Post a Comment