none
Treeview return to selected node RRS feed

  • Question

  • Hi,

    Sorry if this has been done but I have searched and not found the answer.

    I have a treeview with nodes and child nodes.
    A child node is selected and data shown on another form.
    When I return to the treeview it gets reloaded, so obviously the treeview is in a colapsed state.

    I want to store the selected node at the point it's double clicked and return to that node once the treeview is reloaded.

    I could use the TAG but thought there may be a better way to do it.

    Cheers,
    Gary
    Monday, November 24, 2008 4:16 PM

Answers

  • You could try this if you are opening you form modally and coming back to the original form.


    Private myNode As String

    Private Sub TreeView1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TreeView1.MouseDoubleClick

    myNode = TreeView1.SelectedNode.Text

    Dim
    x As New WhatEverYourFormNameIs

    x.ShowDialog()

    Dim
    node As TreeNode() = TreeView1.Nodes.Find(myNode, True)

    TreeView1.SelectedNode = node(0)

    node(0).EnsureVisible

    myNode = nothing

    End
    Sub

    • Marked as answer by GaryR Thursday, November 27, 2008 2:02 PM
    Monday, November 24, 2008 6:00 PM