VB.NET ListBox Control
The ListBox control is used to display a list of items in Windows form. It allows the user to select one or more items from the ListBox Control. Furthermore, we can add or design the list box by using the properties and events window at runtime.
Let's create a ListBox control in the VB.NET Windows by using the following steps.
Step 1: Drag the ListBox control from the Toolbox and drop it to the Windows form, as shown below.
Step 2: Once the ListBox is added to the Form, we can set various properties of the Listbox by clicking on the ListBox control.
There are following properties of the ListBox control.
||It takes a value that defines whether the list box allows the user to select the item from the list.
||It obtains a value that determines whether the Listbox control can be selected.
||It is used to get or set the width of the columns in a multicolumn Listbox.
||As the name defines, a container gets the IContainer that stores the component of ListBox control.
||It is used to get the collection of controls contained within the control.
||It takes a value that determines whether the control is created or not.
||It is used to set the width of the ListBox control.
||It takes a value that determines whether the ListBox control and all its child are displayed on the Windows Form.
||It is used to get or set the method that determines which items are selected in the ListBox.
||It allows multiple columns of the item to be displayed by setting the True value in the Listbox.
||The Add() method is used to add items to an item collection.
||It is used to remove an item from an item collection. However, we can remove items using the item name.
||It is used to remove all items from the item collection at the same time.
||It is used to check whether the particular item exists in the ListBox or not.
||It is used to display the control to the user.
||As the name suggests, a Sort() method is used to arrange or sort the elements in the ListBox.
||A ResetText() method is used to reset ListBox's text property and set the default value.
||It is used to reset the backColor property of the ListBox and set the default value.
||It is used to notify the message of the ListBox to Windows.
||The GetSelected method is used to validate whether the specified item is selected.
Furthermore, we can also refer to VB.NET Microsoft documentation to get a complete list of ListBox properties, and methods.
Let's create a program to select an item from the ListBox in the VB.NET form.
Now select an item from the list. We have selected Jupiter.
Click on the Show button to display the selected item in Windows Form, as follows.