Results 1 to 6 of 6

Thread: Setting the currrent selected treeview node

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2003
    Posts
    4

    Arrow Setting the currrent selected treeview node

    I have a tree view that loads the details of an item into another panel. If those items are edited, and the user selects another tree view item, they are asked if they want to save changes. If they click Cancel, then the original node needs to be reselected. However, the problem is that it appears all of the node selected properties are read-only. Is there a way to set the selected node?

    I've tried stuff like...

    Code:
    tvwSwatches.SelectedNode = tvwSwatches.Nodes(CurrentSwatchNode)
    But that throws System.ArgumentOutOfRangeException

    Any ideas?
    _motr_

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    What is CurrentSwatchNode set to in your test? Remember that you have to follow the hierarchy structure of the nodes. Maybe this will help: http://www.vbforums.com/showthread.p...hreadid=236652

  3. #3
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    why dont you just do
    tvwSwatches.SelectedNode = CurrentSwatchNode
    ?
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  4. #4

    Thread Starter
    New Member
    Join Date
    Oct 2003
    Posts
    4
    CurrentSwatchNode is an integer that is assigned the node index when the user first selects it. The node tree isn't changing, so I'm assuming this method would work (either this or getting the node with its path)
    _motr_

  5. #5
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    well you could just save the node as a TreeNode, and I think it would work
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  6. #6
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Yeah saving a reference to the node itself would be much easier. Then you can use the code MrPolite posted.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width