01.
Private
Sub
CreateMyListView()
02.
03.
Dim
listView1
As
New
ListView()
04.
listView1.Bounds =
New
Rectangle(
New
Point(10, 10),
New
Size(300, 200))
05.
06.
07.
listView1.View = View.Details
08.
09.
listView1.LabelEdit =
True
10.
11.
listView1.AllowColumnReorder =
True
12.
13.
listView1.CheckBoxes =
True
14.
15.
listView1.FullRowSelect =
True
16.
17.
listView1.GridLines =
True
18.
19.
listView1.Sorting = SortOrder.Ascending
20.
21.
22.
Dim
item1
As
New
ListViewItem(
"item1"
, 0)
23.
24.
item1.Checked =
True
25.
item1.SubItems.Add(
"1"
)
26.
item1.SubItems.Add(
"2"
)
27.
item1.SubItems.Add(
"3"
)
28.
Dim
item2
As
New
ListViewItem(
"item2"
, 1)
29.
item2.SubItems.Add(
"4"
)
30.
item2.SubItems.Add(
"5"
)
31.
item2.SubItems.Add(
"6"
)
32.
Dim
item3
As
New
ListViewItem(
"item3"
, 0)
33.
34.
item3.Checked =
True
35.
item3.SubItems.Add(
"7"
)
36.
item3.SubItems.Add(
"8"
)
37.
item3.SubItems.Add(
"9"
)
38.
39.
40.
41.
listView1.Columns.Add(
"Item Column"
, -2, HorizontalAlignment.Left)
42.
listView1.Columns.Add(
"Column 2"
, -2, HorizontalAlignment.Left)
43.
listView1.Columns.Add(
"Column 3"
, -2, HorizontalAlignment.Left)
44.
listView1.Columns.Add(
"Column 4"
, -2, HorizontalAlignment.Center)
45.
46.
47.
listView1.Items.AddRange(
New
ListViewItem() {item1, item2, item3})
48.
49.
50.
Dim
imageListSmall
As
New
ImageList()
51.
Dim
imageListLarge
As
New
ImageList()
52.
53.
54.
imageListSmall.Images.Add(Bitmap.FromFile(
"C:\MySmallImage1.bmp"
))
55.
imageListSmall.Images.Add(Bitmap.FromFile(
"C:\MySmallImage2.bmp"
))
56.
imageListLarge.Images.Add(Bitmap.FromFile(
"C:\MyLargeImage1.bmp"
))
57.
imageListLarge.Images.Add(Bitmap.FromFile(
"C:\MyLargeImage2.bmp"
))
58.
59.
60.
listView1.LargeImageList = imageListLarge
61.
listView1.SmallImageList = imageListSmall
62.
63.
64.
Me
.Controls.Add(listView1)
65.
End
Sub