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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. getting first root node of treeview

getting first root node of treeview

Scheduled Pinned Locked Moved C / C++ / MFC
csharpdotnetdata-structuresquestion
6 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.
  • T Offline
    T Offline
    Trucker
    wrote on last edited by
    #1

    Hi, I am using TreeView.TopNode to get the first root node of my treeview. This does not work for me all the time however. If you read the .NET Framework on this property, I think they state this also by saying: Initially, the TopNode returns the first root tree node, which is located at the top of the TreeView. However, if the user has scrolled the contents, another tree node might be at the top. I don't understand why the TopNode would return a different node after a user scrolled through the treeview.:confused: Does anybody know why? And in this case, how else could I get the first root node? Thanks. TraileR ParK LifE 4Ever

    D J 2 Replies Last reply
    0
    • T Trucker

      Hi, I am using TreeView.TopNode to get the first root node of my treeview. This does not work for me all the time however. If you read the .NET Framework on this property, I think they state this also by saying: Initially, the TopNode returns the first root tree node, which is located at the top of the TreeView. However, if the user has scrolled the contents, another tree node might be at the top. I don't understand why the TopNode would return a different node after a user scrolled through the treeview.:confused: Does anybody know why? And in this case, how else could I get the first root node? Thanks. TraileR ParK LifE 4Ever

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      One way would be to get the top node and save it in a member variable. That way you'll always have access to the top node no matter what amount of scrolling has transpired.


      "One must learn from the bite of the fire to leave it alone." - Native American Proverb

      T 1 Reply Last reply
      0
      • T Trucker

        Hi, I am using TreeView.TopNode to get the first root node of my treeview. This does not work for me all the time however. If you read the .NET Framework on this property, I think they state this also by saying: Initially, the TopNode returns the first root tree node, which is located at the top of the TreeView. However, if the user has scrolled the contents, another tree node might be at the top. I don't understand why the TopNode would return a different node after a user scrolled through the treeview.:confused: Does anybody know why? And in this case, how else could I get the first root node? Thanks. TraileR ParK LifE 4Ever

        J Offline
        J Offline
        Jose Lamas Rios
        wrote on last edited by
        #3

        TopNode returns "the first fully-visible tree node in the tree view control". That is, it only considers those nodes that are currently visible, and that's why its result may vary if the user has scrolled. If what you want is the absolute first root node, I think it should be the first element of the collection you get through the Nodes propety. -- jlr http://jlamas.blogspot.com/[^]

        T 1 Reply Last reply
        0
        • D David Crow

          One way would be to get the top node and save it in a member variable. That way you'll always have access to the top node no matter what amount of scrolling has transpired.


          "One must learn from the bite of the fire to leave it alone." - Native American Proverb

          T Offline
          T Offline
          Trucker
          wrote on last edited by
          #4

          Thanks for the reply David. I simply chose to just get the first root node through the treeview.Nodes.get_Item(0) property, like Jose suggested but your way definitely works as well. Thanks. TraileR ParK LifE 4Ever

          D 1 Reply Last reply
          0
          • J Jose Lamas Rios

            TopNode returns "the first fully-visible tree node in the tree view control". That is, it only considers those nodes that are currently visible, and that's why its result may vary if the user has scrolled. If what you want is the absolute first root node, I think it should be the first element of the collection you get through the Nodes propety. -- jlr http://jlamas.blogspot.com/[^]

            T Offline
            T Offline
            Trucker
            wrote on last edited by
            #5

            Ofcourse! Here I go again thinking 'inside the box';P. Although I don't see the use of a function like TopNode that returns the first fully visible node... I mean cmon, who would want to get a node like that? Anyways, your answer is exactly what I was looking for. Thanks again:) TraileR ParK LifE 4Ever

            1 Reply Last reply
            0
            • T Trucker

              Thanks for the reply David. I simply chose to just get the first root node through the treeview.Nodes.get_Item(0) property, like Jose suggested but your way definitely works as well. Thanks. TraileR ParK LifE 4Ever

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              /*Trucker*\ wrote: I simply chose to just get the first root node through the treeview.Nodes.get_Item(0) property, like Jose suggested... Which is a much cleaner solution. I'm not familiar with the .Net stuff so some of my answers are not always straight forward.


              "One must learn from the bite of the fire to leave it alone." - Native American Proverb

              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