VB.NET ListView Control

The ListView Controls are used to display a collection of items in the Windows Forms. It uses one of the view lists, such as LargeIcon, SmallIcon, Details, List, and Tile. Furthermore, the ListView allows the user to add or remove icons from the ListView Control.

Let's create a ListView control in the VB.NET Windows form by using the following steps.

Step 1: We have to find the ListView control from the toolbox and then drag and drop the ListView control onto the window form, as shown below.

VB.NET ListView Control

Step 2: Once the ListView is added to the form, we can set various properties of the List by clicking on the ListView control.

Properties of the ListView Control

There are following properties of ListView control.

PropertiesDescription
AlignmentThe Alignment property is used to set the alignment for the item in the ListvVew Control.
ActivationThe Activation property is used to get or set a user-requested action to activate an item.
CheckBoxesThe CheckBoxes property sets a value to display the checkbox that appears next to each item in the list view control.
ColumnsThe Columns property is used to display the collection of columns header in the ListView Control.
CheckIndicesThe CheckIndices property is used to get all checked items in the ListView Control.
GridLinesThe GridLines Property is used to display the gridlines between the rows and columns that contain the items and subitems in the ListView Control.
ItemsIt is used to collect the collection of the items that are in the ListView Control.
LargeImageListIt is used to set or get ImageList to display it as a large icon in the ListView Control.
HeaderStyleIt is used to set or get the column header style in the ListView control.
MultiSelectThe MultiSelect property is used to set a value that allows selecting more than items in the ListView control.
SelectedItemsIt is used to obtain all selected items in the ListView control.
ShowGroupsThe ShowGroups property set a value that represents whether the ListView items are displayed in groups.
SmallImageListIt is used to set or get ImageList to display the image as a small icon in the ListView control.
TopItemThe TopItem property is used to set or get the first item in control.
ViewThe View property is used to set the items displayed in the List view. The View property has the following values:
SmallIcon: It is used to display small size icons.
List: It is used to display items in a list, and it only shows captions.
LargeIcon: It is used to display large size icons.
Report: It is used to display items and its sub-items.

Methods of the ListView Control

MethodDescription
ArrangeIcons()The ArrangeIcons method is used to arrange all the items displayed as icons in the ListView control.
FindItemWithText()It is used to search the first ListViewItem that started with the given text value.
GetItemAt()The GetItemAt method is used to get an item at the specified location of the ListView control.
Clear()The Clear method is used to clear all the items and columns from the ListView control.
Sort()The Sort method is used to sort items of the ListView.

Events of the ListView Control

There are following events of the ListView control.

EventsDescription
ItemActivateThe ItemActivate event occurred when an item activated in the ListView control.
ItemCheckedThe ItemChecked event is found in the ListView control when the checked state of an item changes.
TextChangedThe TextChanged event is found in the ListView control when the property of the text changes.
ItemCheckWhen the status of a check item changes, the ItemCheck event is found in the list view control.
AfterLabelEditEventIt occurs when the user in the ListView control edits the label for an item.

Let's create a program to insert the records in the ListView control of the VB.NET Windows form.

List_View.vb

Output:

VB.NET ListView Control

Now, we fill all the details of the Student that is asked in the Form.

VB.NET ListView Control

Now, click on the Add New Entry button. It displays the record in the ListView control or in Student details table, as shown below.

VB.NET ListView Control

Similarly, we have added the following student details in the form.

VB.NET ListView Control




Latest Courses