Results 1 to 6 of 6

Thread: TreeView Question

  1. #1

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    TreeView Question

    If a user selects something, how can I get the text of what is selected?

    Like say I have this:
    Code:
    My Program|
                       |Hello World
                       |Never!
    If the user selects "Never!", how can I just get the text "Never!"? I am NOT interested in the node number, jsut the text and the order may be different all the time.

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I don't know if this is what you mean :

    VB Code:
    1. MessageBox.Show(TreeView1.Nodes.Item(TreeView1.SelectedNode.Index).Text)

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Put that code in this event : TreeView1_AfterSelect or if you put it in a Button , then you must make sure that an item is selected .

  4. #4

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by Pirate
    I don't know if this is what you mean :

    VB Code:
    1. MessageBox.Show(TreeView1.Nodes.Item(TreeView1.SelectedNode.Index).Text)
    Does not work correctly

    I am putting it into a string so I can use it, however, when I highlight an item and use a button on a context menu, it will copy the 3rd root node into the string and not the selected item. If I try to click the button again, it closes and said it operated out of the range or something....


  5. #5
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    MessageBox.Show(TreeView1.SelectedNode.Text)

  6. #6

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by Edneeis
    MessageBox.Show(TreeView1.SelectedNode.Text)
    thanks

    though I don't know why I didn't use that in the first place.... =/

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