Double-click Event for the TreeView control

Source: Internet
Author: User
Treeview| Control This example implements double node, pop-up dialog box and display node information

First add some data to the TREEVIEW1 code as follows:

Sub Example ()

Dim N as New TreeNode, I As Integer, J as Integer

For I = 0 to 3

With N.nodes.add ((I * 15). ToString & "-" & ((I + 1) * 15-1). ToString)

For J = 0 to 14

. Nodes.Add (J + I * 15). ToString)

Next

End With

Next

Dim Nodetoadd as TreeNode

For I = 1 to 24

Nodetoadd = N.clone

Nodetoadd.text = i.tostring

TREEVIEW1.NODES.ADD (Nodetoadd)

Next

End Sub



Add the following code to the Treeview1_click event:



Dim N as TreeNode = CType (sender, Windows.Forms.TreeView). SelectedNode

'//If the tree node is not 0, the message is displayed.

If N.getnodecount (False) = 0 Then

'//The text character of the current node

Dim S as String = N.text

'//If the character length is 1, then add 0 before

If s.length = 1 Then

S = S.insert (0, "0") '//insert character at specified position

End If

'//The characters of the previous tree node alphanumeric the current node

s = n.parent.text & ":" & S

'//Of course you can also show the character of the parent node again

'//code becomes: S=n.parent.parent.text & ":" & S

MessageBox.Show ("The section character you select is:" & S)

End If



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.