TreeView Control Problem ?
-
Hi every body , i have a treeview control in windows mobile 5.0 pocket pc , i want when the user select a node to clear all other nodes , i try to do it but it does not work , so can i find some help ?? Thanks , :) Mona
LA ELAH ELA ALLAH MOHAMED RASOL ALLAH
-
Hi every body , i have a treeview control in windows mobile 5.0 pocket pc , i want when the user select a node to clear all other nodes , i try to do it but it does not work , so can i find some help ?? Thanks , :) Mona
LA ELAH ELA ALLAH MOHAMED RASOL ALLAH
Hello Mona, I tried using the following code and it worked for me: Me.TreeView1.Nodes.Clear() Are you doing anything different? If yes, can you post the code snippet you are using? Regards, Dave
Dave Traister Software Engineer ComponentOne LLC www.ComponentOne.com
-
Hello Mona, I tried using the following code and it worked for me: Me.TreeView1.Nodes.Clear() Are you doing anything different? If yes, can you post the code snippet you are using? Regards, Dave
Dave Traister Software Engineer ComponentOne LLC www.ComponentOne.com
thanks dave for your reply , i already use this code but the problem was : i have parent nodes which have a child nodes and the child nodes have also childes and all data returned from a database . so to make the performance better , i have when the user select any node to clear all other expanded nodes which was selected before so i wrote this code For i As Integer = 0 To TreeView1.Nodes.Count - 1 If (i <> e.Node.Index) Then TreeView1.Nodes(i).Nodes.Clear() End If Next and it works but not totally correct , when i select a parent node and then select another it works and clear all the childes nodes under the selected node , but when i select a child node which has sub childes it clear the parent of this node and it's normal because the index here has changed ??? that's the problem !:confused:
LA ELAH ELA ALLAH MOHAMED RASOL ALLAH
-
thanks dave for your reply , i already use this code but the problem was : i have parent nodes which have a child nodes and the child nodes have also childes and all data returned from a database . so to make the performance better , i have when the user select any node to clear all other expanded nodes which was selected before so i wrote this code For i As Integer = 0 To TreeView1.Nodes.Count - 1 If (i <> e.Node.Index) Then TreeView1.Nodes(i).Nodes.Clear() End If Next and it works but not totally correct , when i select a parent node and then select another it works and clear all the childes nodes under the selected node , but when i select a child node which has sub childes it clear the parent of this node and it's normal because the index here has changed ??? that's the problem !:confused:
LA ELAH ELA ALLAH MOHAMED RASOL ALLAH
You can try creating a function to clear the nodes and call it recursively for child nodes as shown below: Private Function ClearChildren(objTV As TreeView, strParentNode As String) as Boolean On Error Goto Hell Dim i As Long 'Use a reference to the Parent node With objTV.Nodes(strParentNode) 'Loop through the children For i = 1 To .Children 'Determine if the child has a sub node If .Child.Children > 0 Then 'Recurse this method ClearChildren objTV, .Child End If 'Clear the node objTV.Nodes.Remove .Child.Index Next End With 'Success ClearChildren = True Exit Function Hell: End Function Regards, Dave
Dave Traister Software Engineer ComponentOne LLC www.ComponentOne.com