Pages

Friday 21 February 2014

How to use the Imagelist to make Icon of Listvew Control in Vb.Net


Imagelist is a control that has a capability to store Pictures and icons to use from the other control like label, Listview and other control that support icons and images. It has a property that can be able to set the size of picture to be display to corresponding controls.

How to use?



       * Here is the steps to be follow.

First Step
Drag the Imagelist control which can be found "All Windows Forms Tab" in tools into form.


Second Step
Go to the Property of Imagelist and set the Imagesize to be import.

Third Step
Go to Image Property and click on the left side on "Collection..."  and Import an Image or Icons


Fourth Step
Add an Listview Control to your Form

Last Steps
and Put this code into you Form_Load Event Arguments

Dim lvColumnHeader As ColumnHeader ListView1.View = View.Details ListView1.TileSize = New Size(400,
100) ListView1.Items.AsParallel() lvColumnHeader = ListView1.Columns.Add("Name") 
lvColumnHeader.Width = 100 lvColumnHeader = ListView1.Columns.Add("Description") lvColumnHeader.Width = 100 lvColumnHeader = ListView1.Columns.Add("Files Size") lvColumnHeader.Width = 100 ListView1.LabelWrap = True

Dim lvItem As New ListViewItem ListView1.UseCompatibleStateImageBehavior = False
lvItem = ListView1.Items.Add("Watchman", 3)
 lvItem.ImageIndex = 0
 lvItem.SubItems.AddRange(New String() {"The Leader of Watch out", "1000 Files"})

 ListView1.UseCompatibleStateImageBehavior = False
 lvItem = ListView1.Items.Add("Login", 3)
lvItem.ImageIndex = 2
 lvItem.SubItems.AddRange(New String() {"The Information of User to login", "200 Records"})

 ListView1.UseCompatibleStateImageBehavior = False
 lvItem = ListView1.Items.Add("Controls Finders", 3)
 lvItem.ImageIndex = 1
 lvItem.SubItems.AddRange(New String() {"Watch the New Control of System", "10 Records"})

Run Your Program.

No comments:

Post a Comment