Resolved TreeView Node Expands

aaaron

Well-known member
Joined
Jan 23, 2011
Messages
219
Programming Experience
10+
VB.NET:
Private Sub TreeView_1_AfterSelect(sender As Object, e As TreeViewEventArgs) Handles TreeView_1.AfterSelect
    Try
        Debug.WriteLine(e.Node.IsExpanded)
        Me.TextBox_LastSelected.Text = CStr(e.Node.Tag)
        Debug.WriteLine(e.Node.IsExpanded)
    Catch ex As Exception
        MessageBox.Show("ex.message")
    End Try
End Sub

I have a TreeView that when I select a node it expands. I don't want it to expand unless the user clicks the expand symbol.

I replaced the code I had in the AfterSelect Sub with the above test code.
It prints False then True.
If I replace CStr(e.Node.Tag) with "JUNK" it prints False then False, which is the desired behavior.
But I need to copy the Tag into the Text!

Is there a way to get the desired behavior?
 
Solution
By default treenode will only expand on doubleclick or clicking expand icon. Treeview also doesn't have any setting to allow singleclick expand. So it sounds like you have added code somewhere to expand.
By default treenode will only expand on doubleclick or clicking expand icon. Treeview also doesn't have any setting to allow singleclick expand. So it sounds like you have added code somewhere to expand.
 
Solution
I have to agree with @JohnH. It sounds like you're handling the TextChanged event of TextBox_LastSelected and expanding the node if you find a match to the Text. You can obviously look at the code to see but you should also be able to type into that TextBox and see if the specified node expands.
 

Latest posts

Back
Top