本文整理汇总了C#中System.Windows.Forms.TreeView.HotTracking属性的典型用法代码示例。如果您正苦于以下问题:C# TreeView.HotTracking属性的具体用法?C# TreeView.HotTracking怎么用?C# TreeView.HotTracking使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Windows.Forms.TreeView
的用法示例。
在下文中一共展示了TreeView.HotTracking属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CustomizedTreeView
public class CustomizedTreeView : TreeView
{
public CustomizedTreeView()
{
// Customize the TreeView control by setting various properties.
BackColor = System.Drawing.Color.CadetBlue;
FullRowSelect = true;
HotTracking = true;
Indent = 34;
ShowPlusMinus = false;
// The ShowLines property must be false for the FullRowSelect
// property to work.
ShowLines = false;
}
protected override void OnAfterSelect(TreeViewEventArgs e)
{
// Confirm that the user initiated the selection.
// This prevents the first node from expanding when it is
// automatically selected during the initialization of
// the TreeView control.
if (e.Action != TreeViewAction.Unknown)
{
if (e.Node.IsExpanded)
{
e.Node.Collapse();
}
else
{
e.Node.Expand();
}
}
// Remove the selection. This allows the same node to be
// clicked twice in succession to toggle the expansion state.
SelectedNode = null;
}
}
示例2: ImageList
//引入命名空间
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
public class Form1 : System.Windows.Forms.Form {
private System.Windows.Forms.TreeView treeView1;
ImageList il = new ImageList();
public Form1() {
this.treeView1 = new System.Windows.Forms.TreeView();
this.SuspendLayout();
this.treeView1.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right);
this.treeView1.Font = new System.Drawing.Font("Courier New", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.treeView1.HotTracking = true;
this.treeView1.ImageIndex = -1;
this.treeView1.Indent = 30;
this.treeView1.ItemHeight = 30;
this.treeView1.LabelEdit = true;
this.treeView1.Location = new System.Drawing.Point(8, 16);
this.treeView1.SelectedImageIndex = -1;
this.treeView1.Size = new System.Drawing.Size(360, 272);
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(376, 309);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.treeView1});
this.Text = "TreeView Control";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
[STAThread]
static void Main() {
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e) {
il.Images.Add(new Icon("1.ICO"));
il.Images.Add(new Icon("2.ICO"));
il.Images.Add(new Icon("3.ICO"));
il.Images.Add(new Icon("4.ICO"));
treeView1.ImageList = il;
TreeNode rootNode = treeView1.Nodes.Add("USA");
rootNode.ImageIndex = 0;
TreeNode states1 = rootNode.Nodes.Add("a");
states1.ImageIndex = 1;
TreeNode states2 = rootNode.Nodes.Add("b");
states2.ImageIndex = 1;
TreeNode states3 = rootNode.Nodes.Add("c");
states3.ImageIndex = 1;
TreeNode states4 = rootNode.Nodes.Add("d");
states4.ImageIndex = 1;
TreeNode child = states1.Nodes.Add("A");
child.ImageIndex = 2;
child = states1.Nodes.Add("e");
child.ImageIndex = 2;
child = states1.Nodes.Add("f");
child.ImageIndex = 2;
child = states2.Nodes.Add("g");
child.ImageIndex = 2;
child = states2.Nodes.Add("h");
child.ImageIndex = 2;
child = states2.Nodes.Add("i");
child.ImageIndex = 2;
child = states3.Nodes.Add("j");
child.ImageIndex = 2;
child = states3.Nodes.Add("k");
child.ImageIndex = 2;
child = states3.Nodes.Add("l");
child.ImageIndex = 2;
child = states4.Nodes.Add("m");
child.ImageIndex = 2;
child = states4.Nodes.Add("n");
child.ImageIndex = 2;
child = states4.Nodes.Add("o");
child.ImageIndex = 2;
}
}