Results 1 to 8 of 8

Thread: [RESOLVED] Treeview selection

  1. #1

    Thread Starter
    Hyperactive Member jlt7's Avatar
    Join Date
    Jan 2006
    Posts
    413

    Resolved [RESOLVED] Treeview selection

    I have this code here, It will expand the treeview to the item but doesn't select it. I would like for it to select it just as if I clicked on it.
    If anyone can help me with this I would sure appreciate it, Thank you.

    VB Code:
    1. Dim i As Integer
    2.     For i = 1 To frmmain.TreList.Nodes.Count
    3.         If frmmain.TreList.Nodes(i).Text = lstSearch.SelectedItem.Text Then
    4.             frmmain.TreList.Nodes(i).Selected = True
    5.                 Exit For
    6.         End If
    7.     Next i

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Treeview selection

    Set the Treeview.HideSelection property to False.

  3. #3

    Thread Starter
    Hyperactive Member jlt7's Avatar
    Join Date
    Jan 2006
    Posts
    413

    Re: Treeview selection

    That didn't do it either brucevde, Still expands the treeview and doesn't select the treeview item that I selected from my listview.
    Thank you for the help tho.

  4. #4
    Frenzied Member
    Join Date
    Jun 2006
    Posts
    1,098

    Re: Treeview selection

    Try calling the treeview's click event procedure after selecting the node: Call TreList_Click

  5. #5
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Treeview selection

    If HideSelection is True, the Treeview does not highlight the selected Node unless it has Focus. If HideSelection is False, the Treeview highlights the selected Node using a gray background if it does not have Focus and normal highlighting with Focus.

    Highlighting is either on or off. If you are not seeing any highlighting when HideSelection = False, then there is a problem elsewhere in your code.
    Last edited by brucevde; Feb 16th, 2007 at 06:14 PM.

  6. #6

    Thread Starter
    Hyperactive Member jlt7's Avatar
    Join Date
    Jan 2006
    Posts
    413

    Re: Treeview selection

    Ok, yes it does that but what I mean is I would like for it to act as if I clicked on it and fill my textbox and so forth. Is there a way to do that or do I have to code it in a differrent way for it to do that.

  7. #7
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Treeview selection

    Sorry. I misunderstood what you meant...

    Which event do you want to fire? Treeview_NodeClick or Treeview_Click.

    Regardless, you will have to call the event directly.

    VB Code:
    1. Dim i As Integer
    2.     For i = 1 To frmmain.TreList.Nodes.Count
    3.         If frmmain.TreList.Nodes(i).Text = lstSearch.SelectedItem.Text Then
    4.             frmmain.TreList.Nodes(i).Selected = True
    5.             frmMain.TreList_NodeClick frmmain.TreList.Nodes(i)
    6.                 Exit For
    7.         End If
    8.     Next i

    You will need to change the TreList_NodeClick procedure from Private to Public.

  8. #8

    Thread Starter
    Hyperactive Member jlt7's Avatar
    Join Date
    Jan 2006
    Posts
    413

    Re: Treeview selection

    No problem, That happens.
    Sorry. I misunderstood what you meant...
    But, the good news is that it worked finally.
    Thank you for the help.

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