Please Help Me Understand This Bizarre Tree Entry Observation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tom

    Please Help Me Understand This Bizarre Tree Entry Observation

    My older system: Win2k, VS2005(Academic ), .Net 2.0 SP1.

    Windows.Forms Application: Two splitter panels, a TreeView (named:
    "tree") in one panel populated with directory name nodes.

    Logic for programmaticall y selecting a previously saved FullPath is
    being called from the tree.Enter() event handler;

    After expanding to a specific folder and selecting it (for testing
    purposes I chose a specific folder that is level 4 depth) ... I
    observe a difference between tabbing into the tree control and mouse
    clicking into it. I have placed the following line at the beginning of
    the Enter event handler:

    Console.Writeli ne("tree.Select edNode = {0}", tree.SelectedNo de);

    ----------------------------------------------------
    The problem >>>

    When I tab into the tree control, above line output is:

    tree.SelectedNo de =

    When I click into the tree control, the output is:

    tree.SelectedNo de = TreeNode: G:\

    ----------------------------------------------------
    The "G" drive is correct for the folder selected. This subtle little
    SelectedNode value difference is wreaking havoc on my code that
    programmaticall y selects a previously saved folder location.

    I've tried a variety of guesses aimed at gaining some control and
    understanding of what is going on ... but all of them are failures and
    discussing them only confuses the issue. :(

    I might eventually stumble onto a novice programmer level solution ...
    but I'd be so much better off understanding what is going on and how
    to properly control the property settings of the TreeView object.

    Specific guidance to the above problem would be wonderful !!

    Additional TreeView advice or example code on programmatic selection
    would be equally appreciated. Suggested texts, links, etc. I'm not
    lazy ... but perhaps as evidenced from the hours I've spent searching
    and the days of confusion this has caused me it is fair to say I'm not
    exactly "gifted". ;)

    ** Thanks in advance for any help !! **

    -- Tom





  • Peter Duniho

    #2
    Re: Please Help Me Understand This Bizarre Tree Entry Observation

    On Thu, 06 Mar 2008 14:25:16 -0800, Tom <Thomas-911@earthlink.n etwrote:
    [...] I have placed the following line at the beginning of
    the Enter event handler:
    >
    Console.Writeli ne("tree.Select edNode = {0}", tree.SelectedNo de);
    >
    ----------------------------------------------------
    The problem >>>
    >
    When I tab into the tree control, above line output is:
    >
    tree.SelectedNo de =
    >
    When I click into the tree control, the output is:
    >
    tree.SelectedNo de = TreeNode: G:\
    >
    ----------------------------------------------------
    The "G" drive is correct for the folder selected. This subtle little
    SelectedNode value difference is wreaking havoc on my code that
    programmaticall y selects a previously saved folder location.
    Well, when you tab into the control, is there actually a node selected?
    Or is there simply a focus rectangle around one of the nodes?

    I would expect the SelectedNode property to be a reliable source of
    information regarding what's selected, if anything. So if it's not
    returning a node, it seems likely that no node is selected at that moment.

    Barring that, you should post a concise-but-complete code sample that
    reliably demonstrates the problem you're having.

    Pete

    Comment

    • Tom

      #3
      Re: Please Help Me Understand This Bizarre Tree Entry Observation

      Thanks Pete !

      I will try to explore if somewhere in my other event handlers within
      this project if somehow the SelectedNode becomes null. At this time
      there is no concise way for me to duplicate the observation ... but I
      will try. The observed problem is in a project that has grown to a few
      thousand lines of code and there are a lot of interactions between the
      panels.

      Searching for the precise location where the SelectedNode becomes null
      will hopefully reveal some additional insights into the combination of
      events that I am trying to coordinate. I suffered immensely from using
      too many events early on and have been trying to reduce the calling of
      events as much as possible. Typical rookie mistake perhaps. Observe
      something not behaving correctly, don't understand it, search through
      the lists of events for something to cure the symptom ... all the
      while not recognizing and treating the cause.

      I've caught a few of my TreeView populating mistakes by writing out
      detailed Nodes[].Name tables. I wish the texts I've read concentrated
      more on troubleshooting rather than presenting a minimalist
      pedagogical and well polished example. But then ... would the readers
      appreciate it? Or the publishers print it?

      Your comment has me re-energized and thinking again.

      Thanks !!

      -- Tom


      Comment

      Working...