Hi @Mansour_Dalir ,
You can refer to the following code.
Private Function CheckSingleChildRootNodes(ByVal treeView As TreeView) As Boolean
Return treeView.Nodes.Cast(Of TreeNode)().Any(Function(node) CheckSingleNodeAndChildren(node))
End Function
Private Function CheckSingleNodeAndChildren(ByVal node As TreeNode) As Boolean
If node.Nodes.Count <> 1 Then
Return False
End If
Dim childNode As TreeNode = node.Nodes(0)
Return childNode.Nodes.Count = 0 OrElse CheckSingleNodeAndChildren(childNode)
End Function
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.