2021年8月3日 星期二

TreeView TreeNode VB.Net

 Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim t(100) As TreeNode


        Dim namedata = {"", "公司", "部門一", "部門二", "分部一", "分部二", "分部一", "分部二", "人員一", "人員二", "人員一", "人員二", "人員一", "人員二"}

        Dim rr(100) As String


        For dist = 0 To 40 Step 20

            For i = 1 + dist To 12 + dist

                rr(i) = namedata(i - dist)

            Next

        Next


        rr(1) = "公司一"

        rr(21) = "公司二"

        rr(41) = "公司三"

        For dist = 0 To 40 Step 20

            t(1 + dist) = TreeView1.Nodes.Add(rr(1 + dist))

            For i = 2 To 12

                t(i + dist) = t(i \ 2 + dist).Nodes.Add(rr(i + dist))

            Next

        Next

        TreeView1.ExpandAll()

    End Sub

End Class



沒有留言: