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. General Programming
  3. C#
  4. treeView child restrictions

treeView child restrictions

Scheduled Pinned Locked Moved C#
question
8 Posts 3 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.
  • W Offline
    W Offline
    WetRivrRat
    wrote on last edited by
    #1

    I want to display the node text after selection in a label. However i need to restrict this display to only the 3rd-child node in the list so in other words,

    CompanyName

    DeptName
    -
    UserName
    -
    UserPC
    UserPhone#

    • Dept1Name

      **User1Name**
       - 
         User1PC
         User1Phone#
      

    I want to restrict the display of name to only the username, user1name, user2name, etc. nodes, and it needs to stay until the next user name is selected... Once i figure out the restriction portion i'll beable to set the label text static until the next username selection... just would like some assitance with the setting of the node restriction. any ideas? string Beautiful; Beautiful = "ignorant"; label1.Text = "The world is full of " + Beautiful +" people."; Why is common sense such an un-common comodity?

    W D D 3 Replies Last reply
    0
    • W WetRivrRat

      I want to display the node text after selection in a label. However i need to restrict this display to only the 3rd-child node in the list so in other words,

      CompanyName

      DeptName
      -
      UserName
      -
      UserPC
      UserPhone#

      • Dept1Name

        **User1Name**
         - 
           User1PC
           User1Phone#
        

      I want to restrict the display of name to only the username, user1name, user2name, etc. nodes, and it needs to stay until the next user name is selected... Once i figure out the restriction portion i'll beable to set the label text static until the next username selection... just would like some assitance with the setting of the node restriction. any ideas? string Beautiful; Beautiful = "ignorant"; label1.Text = "The world is full of " + Beautiful +" people."; Why is common sense such an un-common comodity?

      W Offline
      W Offline
      WetRivrRat
      wrote on last edited by
      #2

      I'm guessing that everyone was gone for the holidays, So i'm hopping that by adding to this thread will give it some more visiblity...... Help!!!!! string Beautiful; Beautiful = "ignorant"; label1.Text = "The world is full of " + Beautiful +" people."; Why is common sense such an un-common comodity?

      1 Reply Last reply
      0
      • W WetRivrRat

        I want to display the node text after selection in a label. However i need to restrict this display to only the 3rd-child node in the list so in other words,

        CompanyName

        DeptName
        -
        UserName
        -
        UserPC
        UserPhone#

        • Dept1Name

          **User1Name**
           - 
             User1PC
             User1Phone#
          

        I want to restrict the display of name to only the username, user1name, user2name, etc. nodes, and it needs to stay until the next user name is selected... Once i figure out the restriction portion i'll beable to set the label text static until the next username selection... just would like some assitance with the setting of the node restriction. any ideas? string Beautiful; Beautiful = "ignorant"; label1.Text = "The world is full of " + Beautiful +" people."; Why is common sense such an un-common comodity?

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        Easy. Each Node has a Tag property. Just set the Tag property to some value that signifies it as a displayable node.

        TreeNode newNode = new TreeNode();
        // Set Tag to 0 for a NON-Displayable node
        newNode.Tag = 0;
        

        // Set the Tag to 1 for a Displayable node
        newNode.Tag = 1;

        When the user selects a node, check its Tag property to see if it should be displayed in your label. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        W 2 Replies Last reply
        0
        • D Dave Kreskowiak

          Easy. Each Node has a Tag property. Just set the Tag property to some value that signifies it as a displayable node.

          TreeNode newNode = new TreeNode();
          // Set Tag to 0 for a NON-Displayable node
          newNode.Tag = 0;
          

          // Set the Tag to 1 for a Displayable node
          newNode.Tag = 1;

          When the user selects a node, check its Tag property to see if it should be displayed in your label. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

          W Offline
          W Offline
          WetRivrRat
          wrote on last edited by
          #4

          hmm, good catch... but, can't do it all of my nodes (save the root) are loaded by the dataReader, so i am currently loading the node text and tag from the db so i can't edit the tag value unless i create a tag_value coulumn on the db... where i could set the usernames as 1 and all others as 0 unless someone else has a better idea / plan. string Beautiful; Beautiful = "ignorant"; label1.Text = "The world is full of " + Beautiful +" people."; Why is common sense such an un-common comodity?

          1 Reply Last reply
          0
          • D Dave Kreskowiak

            Easy. Each Node has a Tag property. Just set the Tag property to some value that signifies it as a displayable node.

            TreeNode newNode = new TreeNode();
            // Set Tag to 0 for a NON-Displayable node
            newNode.Tag = 0;
            

            // Set the Tag to 1 for a Displayable node
            newNode.Tag = 1;

            When the user selects a node, check its Tag property to see if it should be displayed in your label. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

            W Offline
            W Offline
            WetRivrRat
            wrote on last edited by
            #5

            was thinking about this some more... since the Tag property is of type: object i can pretty much do whatever i want with it, the question just becomes what is the best thing to do? or is simply going with a primative(so-to-speak) 0 or 1 value the best option? :confused: string Beautiful; Beautiful = "ignorant"; label1.Text = "The world is full of " + Beautiful +" people."; Why is common sense such an un-common comodity?

            1 Reply Last reply
            0
            • W WetRivrRat

              I want to display the node text after selection in a label. However i need to restrict this display to only the 3rd-child node in the list so in other words,

              CompanyName

              DeptName
              -
              UserName
              -
              UserPC
              UserPhone#

              • Dept1Name

                **User1Name**
                 - 
                   User1PC
                   User1Phone#
                

              I want to restrict the display of name to only the username, user1name, user2name, etc. nodes, and it needs to stay until the next user name is selected... Once i figure out the restriction portion i'll beable to set the label text static until the next username selection... just would like some assitance with the setting of the node restriction. any ideas? string Beautiful; Beautiful = "ignorant"; label1.Text = "The world is full of " + Beautiful +" people."; Why is common sense such an un-common comodity?

              D Offline
              D Offline
              Darryl Borden
              wrote on last edited by
              #6

              If you want to determine if a specific treenode level, you can use this... int treeNodeLevel=1; TreeNode tn = treenodeToBeTested; while (tn.Parent != null) { tn = tn.Parent; treeNodeLevel++; } You can then say... if (treeNodeLevel == 3) { ...do whatever } Darryl Borden Principal IT Analyst dborden@eprod.com

              W 2 Replies Last reply
              0
              • D Darryl Borden

                If you want to determine if a specific treenode level, you can use this... int treeNodeLevel=1; TreeNode tn = treenodeToBeTested; while (tn.Parent != null) { tn = tn.Parent; treeNodeLevel++; } You can then say... if (treeNodeLevel == 3) { ...do whatever } Darryl Borden Principal IT Analyst dborden@eprod.com

                W Offline
                W Offline
                WetRivrRat
                wrote on last edited by
                #7

                Thanks, I'll have to check this out...as i'm not at a point right now to test it...but i will post the results of my testing shortly string Beautiful; Beautiful = "ignorant"; label1.Text = "The world is full of " + Beautiful +" people."; Why is common sense such an un-common comodity?

                1 Reply Last reply
                0
                • D Darryl Borden

                  If you want to determine if a specific treenode level, you can use this... int treeNodeLevel=1; TreeNode tn = treenodeToBeTested; while (tn.Parent != null) { tn = tn.Parent; treeNodeLevel++; } You can then say... if (treeNodeLevel == 3) { ...do whatever } Darryl Borden Principal IT Analyst dborden@eprod.com

                  W Offline
                  W Offline
                  WetRivrRat
                  wrote on last edited by
                  #8

                  Works like a champ! --had to do a little bit of modification as you had the nodelevel declared as a 1 so it would then increment to 4 before ever actually reaching the desired point...so mod it to a 0 rather than 1 and its pretty...course i could have just changed the if == to value to 4, but then it would not have been the soulution i was looking :-D Thanks a bunch! string Beautiful; Beautiful = "ignorant"; label1.Text = "The world is full of " + Beautiful +" people."; Why is common sense such an un-common comodity?

                  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