> Isn't that what I said?
Couldn't tell what you said <g>
> How do I go about doing that? I can store the complete path or the Node's
> FullPath for later leverage.
fwiw, this works....
'====================
Private Sub Form_Activate()
Static AlreadyBeenHere As Boolean
If Not AlreadyBeenHere Then
AlreadyBeenHere = True
Call SelectNodes
End If
End Sub
Private Sub TreeView1_NodeClick(ByVal Node As ComctlLib.Node)
Dim oNode As Node
Dim sPath As String
Dim sDiv As String
Set oNode = Node
Do
sPath = oNode.Text & sDiv & sPath
sDiv = "|"
Set oNode = oNode.Parent
Loop While Not oNode.Parent Is Nothing
'this stores the updated value each time a node is clicked.
'change as required by your app
Call SaveSetting("MyApp", "Settings", "CurrentNode", sPath)
End Sub
Private Sub SelectNodes()
Dim sPath As String
Dim sNodes() As String
Dim lNode As Long
Dim lLevel As Long
Dim lCurrentNode As Long
sPath = GetSetting("MyApp", "Settings", "CurrentNode", "")
If Len(sPath) > 0 Then
sNodes = Split(sPath, "|")
lCurrentNode = 1
For lLevel = 0 To UBound(sNodes)
For lNode = lCurrentNode To TreeView1.Nodes.Count
If TreeView1.Nodes(lNode).Text = sNodes(lLevel) Then
TreeView1.Nodes(lNode).Selected = True
TreeView1.Nodes(lNode).Expanded = True
lCurrentNode = lNode
Exit For
End If
Next
Next
End If
End Sub
'====================

Signature
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
In Loving Memory - http://www.vbsight.com/Remembrance.htm
MAB - 29 Mar 2007 02:08 GMT
I'm sure this will work. I'll give it a wurle when I get a chance.
Thanks a bunch Ken and Scott.
> > Isn't that what I said?
>
[quoted text clipped - 62 lines]
> End Sub
> '====================
MAB - 29 Mar 2007 16:56 GMT
I ended up using the data populated in the selected Node's FullPath property
which is similar to what you did.
Private Sub cmdOk_Click()
SaveSetting "BBH", "DrawingAccess", "PreviousFullPath",
TreeView1.SelectedItem.FullPath
Me.Hide
End Sub
'This is executred in Form_Load
Sub ExpandToPreviousFolder()
Dim sFullPath As String
Dim sNodes() As String
Dim lNode As Long
Dim lLevel As Long
Dim lCurrentNode As Long
sFullPath = GetSetting("BBH", "DrawingAccess", "PreviousFullPath", "")
If sFullPath <> "" Then
sNodes = Split(sFullPath, "\")
lCurrentNode = 1
For lLevel = 0 To UBound(sNodes)
For lNode = lCurrentNode To TreeView1.Nodes.Count
If TreeView1.Nodes(lNode).Text = sNodes(lLevel) Then
TreeView1.Nodes(lNode).Selected = True
TreeView1.Nodes(lNode).Expanded = True
lCurrentNode = lNode
Exit For
End If
Next
Next
End If
End Sub
Thanks again Ken.
> > Isn't that what I said?
>
[quoted text clipped - 62 lines]
> End Sub
> '====================