Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Mobile Development
  3. Mobile
  4. TreeView Control Problem ?

TreeView Control Problem ?

Scheduled Pinned Locked Moved Mobile
helpquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    monafr81
    wrote on last edited by
    #1

    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

    A 1 Reply Last reply
    0
    • M monafr81

      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

      A Offline
      A Offline
      Arjun Marwaha
      wrote on last edited by
      #2

      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

      M 1 Reply Last reply
      0
      • A Arjun Marwaha

        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

        M Offline
        M Offline
        monafr81
        wrote on last edited by
        #3

        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

        A 1 Reply Last reply
        0
        • M monafr81

          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

          A Offline
          A Offline
          Arjun Marwaha
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups