Hi @Mansour_Dalir ,
You can refer to the following code.
Dim array = (From row In MyDataTable.AsEnumerable()
Select row.ItemArray).ToArray()
For Each item In array
Dim parentNode As TreeNode = Nothing
For i = 0 To item.Length - 1
Dim value = item(i).ToString()
Dim node As TreeNode = Nothing
If parentNode IsNot Nothing Then
node = parentNode.Nodes.Cast(Of TreeNode)() _
.FirstOrDefault(Function(n) n.Text = value)
Else
node = TreeView1.Nodes.Cast(Of TreeNode)() _
.FirstOrDefault(Function(n) n.Text = value)
End If
If node Is Nothing Then
node = New TreeNode(value)
If parentNode IsNot Nothing Then
parentNode.Nodes.Add(node)
Else
TreeView1.Nodes.Add(node)
End If
End If
parentNode = node
Next
Next
Best Regards.
Jiachen Li
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.