Learn how to a build a cloud-first strategyRegister Now


how find previously selected node in treeview

Posted on 2004-11-05
Medium Priority
Last Modified: 2010-04-24
what is the easiest way to find the previously selected node in a treeview?
Question by:brokeMyLegBiking
1 Comment
LVL 86

Accepted Solution

Mike Tomlinson earned 1400 total points
ID: 12508220
You can just store a reference to it like this:

Public Class Form1
    Inherits System.Windows.Forms.Form

    Private prevNode As TreeNode

    Private Sub TreeView1_AfterSelect(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
        Dim curNode As TreeNode = TreeView1.SelectedNode

        If Not ((prevNode Is Nothing)) AndAlso (Not (curNode Is prevNode)) Then
            ' do something with the previous node

        End If

        ' set the previous node to the current node
        prevNode = curNode
    End Sub
End Class

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

804 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question