Visual Basic.NET 7.x (2002/03)Visual Basic 9 (2008)Visual Basic 8 (2005)Visual Basic 6.NET 2.0Windows Forms中级开发.NETVisual Basic
Windows Vista 树形视图






2.64/5 (10投票s)
一个具有 Windows Vista 风格的自定义树形视图。
引言
这是一个提供 Windows Vista 风格的自定义树形视图控件。
背景
代码是 José Manuel Menéndez Poo、Xasthom 和 Stephen J Whiteley 三个人的不同代码的组合。由于大部分代码是由 Stephen 编写的,因此保留了他的版权信息。
这段代码是 SQLmail.org 项目的一部分,这是一个开源项目,旨在创建一个基于 MySQL 的邮件客户端。所有消息都应存储在 SQL 数据库中,这将提供极快的搜索速度。由于我希望整个程序都具有 Windows Vista 风格,因此几乎所有控件都进行了自定义。在 SQLmail.org 项目中,您可以找到一个定制的 Vista 按钮、单选按钮、复选框、工具栏和数据网格,以及如何使用它们。
Using the Code
使用此控件非常简单。从页面顶部的链接下载类,并将其导入到您的项目中。构建您的项目,您将在工具箱中找到它作为一个新的控件。
您可以像这样使用自定义节点
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)