Click here to Skip to main content
15,884,836 members
Articles / Desktop Programming / Windows Forms

Windows Vista Treeview

Rate me:
Please Sign up or sign in to vote.
2.64/5 (10 votes)
12 Feb 2008CPOL 49.3K   2.7K   36   7
A custom made TreeView with Windows Vista look.

Vista_TreeView.jpg

Introduction

This is a custom TreeView control which provides a Windows Vista look.

Background

The code is a combination of three different codes made by José Manuel Menéndez Poo, Xasthom, and Stephen J Whiteley. As most of the code is made by Stephen, his copyright messages have been left.

This code is a part of the SQLmail.org project, an Open Source project whose goal is to make a MySQL based mail client. All messages should be stored in a SQL database which will provide extremely fast search. As I would like to have Windows Vista look for the whole program, almost all controls are customized. In the SQLmail.org project, you can find a Vista customized button, a radio button, a checkbox, a toolstrip, and a datagrid, and the way to use them.

Using the Code

It is very easy to use this control. Download the class from the link at the top of the page and import it in your project. Build your project, and you will find it as a new control in the Toolbox.

You can use a custom node like this:

VB
Dim NewNode As New WindowsVistaNode
NewNode.Name = "myname"
NewNode.Text = "text"
' If you need an icon next to the node, add an ImageList
' on the form, import images in it (Images, Collection),
' on the treeview select the added ImageList in the ImageList property
NewNode.ImageKey = "image.gif" ' name of the image in the ImageList collection
NewNode.SelectedImageKey = "image.gif"
' name of the image which will be drawn when the node is selected, 
' for example, a closed folder for default and an open one for selected

'
' If you want to change a font on the specific node
NewNode.Font = New Font(TreeView1.Font.FontFamily, _
                        TreeView1.Font.Size, FontStyle.Bold)
' Title property is a custom property which allowes you
' to have different sections in a treeview.
' Title node cannot be selected, cannot be closed (always expanded),
' cannot be highlighted when the mouse is hovering
' and the text is always left alligned
NewNode.Title = True
NewNode.Text = UCase(NewNode.Text) ' use it for title nodes
'
Folder_Tree.Nodes.Add(NewNode)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Croatia Croatia
28 years of experience with computers, 8 with BASIC and Z80 assemblers (ZX Spectrum), 6 years VB, 6 years MS Office Macros, 1 year C#, 10 years MS SQL, 1 year MySQL, 5 years ASP and 3 years PHP. Playing with javascript in last couple of months.

Comments and Discussions

 
QuestionModified for TriState? Pin
Tim8w7-Jun-22 6:34
Tim8w7-Jun-22 6:34 
Questiondose it have C++ version ? Pin
haily_lee2-Nov-10 22:51
haily_lee2-Nov-10 22:51 
GeneralIf anyone wants, here is a C# version Pin
Nadeem031927-Sep-09 16:51
Nadeem031927-Sep-09 16:51 
GeneralRe: If anyone wants, here is a C# version Pin
Member 432946918-Jan-10 21:15
Member 432946918-Jan-10 21:15 
GeneralYou fixed the paint issue - well done! Pin
Scott Kane29-Jan-09 2:54
Scott Kane29-Jan-09 2:54 
GeneralRe: You fixed the paint issue - well done! Pin
Member 432946919-Jan-10 12:49
Member 432946919-Jan-10 12:49 
GeneralMy vote of 1 Pin
Member 46377011-Dec-08 8:20
Member 46377011-Dec-08 8:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.