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.
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.
||The Alignment property is used to set the alignment for the item in the ListvVew Control.
||The Activation property is used to get or set a user-requested action to activate an item.
||The CheckBoxes property sets a value to display the checkbox that appears next to each item in the list view control.
||The Columns property is used to display the collection of columns header in the ListView Control.
||The CheckIndices property is used to get all checked items in the ListView Control.
||The GridLines Property is used to display the gridlines between the rows and columns that contain the items and subitems in the ListView Control.
||It is used to collect the collection of the items that are in the ListView Control.
||It is used to set or get ImageList to display it as a large icon in the ListView Control.
||It is used to set or get the column header style in the ListView control.
||The MultiSelect property is used to set a value that allows selecting more than items in the ListView control.
||It is used to obtain all selected items in the ListView control.
||The ShowGroups property set a value that represents whether the ListView items are displayed in groups.
||It is used to set or get ImageList to display the image as a small icon in the ListView control.
||The TopItem property is used to set or get the first item in control.
||The 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
||The ArrangeIcons method is used to arrange all the items displayed as icons in the ListView control.
||It is used to search the first ListViewItem that started with the given text value.
||The GetItemAt method is used to get an item at the specified location of the ListView control.
||The Clear method is used to clear all the items and columns from the ListView control.
||The Sort method is used to sort items of the ListView.
Events of the ListView Control
There are following events of the ListView control.
||The ItemActivate event occurred when an item activated in the ListView control.
||The ItemChecked event is found in the ListView control when the checked state of an item changes.
||The TextChanged event is found in the ListView control when the property of the text changes.
||When the status of a check item changes, the ItemCheck event is found in the list view control.
||It 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.
Now, we fill all the details of the Student that is asked in the Form.
Now, click on the Add New Entry button. It displays the record in the ListView control or in Student details table, as shown below.
Similarly, we have added the following student details in the form.