Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

The List View

List View Fundamentals

Introduction
A list box is used to display a list of strings and all items of that control are primarily strings.
To go a little further than a simple list of strings, the Microsoft Windows operating system
provides the list view control. A list view is used to display a list of items to the user but it can
be configured to change the type of display.

List View Creation


The list view control is made available in the .NET Framework through the ListView class that
is represented in the Windows Forms section of the Toolbox by the list view button. To add a
list view to your application, you can click list view in the Toolbox and click the form or another
container.

To programmatically create a list view, you can declare a variable of type ListView, use
thenew operator to instantiate it and add it to its host's list of controls through a call to
theControls.Add() method. Here is an example:
Imports System.Drawing
Imports System.Windows.Forms
Module Exercise
Public Class Starter
Inherits Form
Private lvwCountries As ListView
Dim components As System.ComponentModel.Container
Public Sub New()
InitializeComponent()
End Sub
Public Sub InitializeComponent()
Text = "Countries Statistics"
Size = New Size(452, 218)
lvwCountries = New ListView()
lvwCountries.Location = New Point(12, 12)
lvwCountries.Width = 420
lvwCountries.Height = 160
Controls.Add(lvwCountries)
End Sub
End Class
Function Main() As Integer
Dim frmStart As Starter = New Starter
Application.Run(frmStart)
Return 0
End Function
End Module

Previous

Copyright 2008-2009, yevol.com

http://www.yevol.com/en/vb/applicationdesign/Lesson30.htm

Next

You might also like