Tip node information when adding a mouse to the TreeView control in WinForm

xiaoxiao2021-03-06  17

WindowsApplication a new project, named WinTreeViewTip, open the form Form1, the TreeView control onto the screen, double-click Form1 named treeView1 into the code-behind page first to add a ToolTip object, named nodeTip: private ToolTip nodeTip = null; then in Form1 Initialization settings in the constructor: this.nodetip = new system.windows.forms.tooltip (); this.nodetip.initialdeLay = 300; this.nodetip.reshowdeLay = 0; // Test Add Node TreeView1.nodes.Add (New Treenode); TreeView1.nodes.add (New Test2 "); TreeView1.nodes.Add (New Test3)); TreeView1.nodes.Add (New Treenode (" test4 ")); InitializeComponent method for adding and MouseLeave treeView1 MouseMove event: // treeView1this.treeView1.MouseMove = new System.Windows.Forms.MouseEventHandler (this.treeView1_MouseMove); this.treeView1.MouseLeave = new System. EventHandler (this.treeView1_MouseLeave); treeView1_MouseMove in treeView1_MouseLeave and add the following code: private void treeView1_MouseLeave (object sender, System.EventArgs e) {nodeTip.Active = true;} private void treeView1_MouseMove (object sender, System.Windows.Forms.MouseEventArgs e ) {TREENODE NODE = TreeView1.Getnodeat (EX, EY); IF (Node == null) {nodetip.active = false;} else {nodetip.Settooltip (TreeView) Sender, node.text); nodetip.active = true;}}

转载请注明原文地址:https://www.9cbs.com/read-41718.html

New Post(0)