Wednesday, December 5, 2012

Customize your TreeView with Images for beginner

Visual Basic offers a simple way to use TreeView and is composing of nodes. TreeView control is very popular to organize file or folders.

In a previous post, I show how to populate a TreeView with nodes and images: TreeView with Images for beginner.

Now, it is time to give more style to your TreeView. Take a look at the picture:

your TreeView

Honestly, the Windows 7 TreeView is much more interesting than the basic one. Yes, both work the same way. Here is some stuff you could do to enhance your TreeView without any big programming.

Remove all the lines in the TreeView:

Set ShowRootLines to false and ShowLines to false to hide all the lines in your TreeView.

        Me.TreeView1.ShowRootLines = False

        Me.TreeView1.ShowLines = False

Remove all the plus minus sign in the TreeView:

Set ShowPlusMinus to false in your TreeView.

        Me.TreeView1.ShowPlusMinus = False

Selection mode to full row select in the TreeView:

Set FullRowSelect to true in your TreeView to make it easier to select your item. Also, it improves the view when the user selects his item.

        Me.TreeView1.FullRowSelect = True

Increase the size of all items in the TreeView:

It is practically impossible to appreciate your program if your TreeView is tiny in your screen.  Raise the default value to something more logical.  Important to remember, it takes Integer values only.

        Me.TreeView1.ItemHeight = 32

Increase the size of your icons or images in the TreeView:

If you raise the height of your TreeView, is realy not a bad idea to raise the height of your icon or image next to the text. You just need to set the value 1 time in the ImaList with ImageSize. I recommend putting 2 identical values to make a beautiful square. If not, you will have a little background effect

        ImageList1.ImageSize = New System.Drawing.Size(24, 24)

Change the background Color in your TreeView

Everyone knows the white background. Nothing will kill you if you change the background for a different color.

        Me.TreeView1.BackColor = Color.DimGray

TreeView Sample

So this ends with the basic changes you could do to your TreeView.
If we take a look to the Windows 7 Start Menu, you see there is a little improvement.

TreeView Sample

Other topics good to read: Extract icon from file
TreeView with Images for beginner

Next Post : Search a file


I invite you to visit my blog for more articles and leave a comment. Check Technologies represents more than 10 years .... Computer and computer aided design.

Check Technologies

235 Adrien-Provencher
Beloeil, (Québec), J3G 0C8, Canada
Tel : 514-705-7690

1 comment: