控件:treeview
代码:
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- For i = 1 To 20
- Dim stt As New TreeNode()
- stt.Name = "teta" & i
- stt.Text = "keenweiwei" & i
- stt.ForeColor = Color.Red
- TreeView1.Nodes.AddRange(New TreeNode() {stt})
- Next
- End Sub
- Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
- MsgBox(TreeView1.SelectedNode.Text)
- End Sub