Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SAVE POSITION IN TREEVIEW

Status
Not open for further replies.

bakerm

Programmer
Joined
Apr 25, 2000
Messages
53
Location
US
I need to know how to reload a treeview control and have it expand out to index the user was previously at. This could be several levels deep at times.

Any help would be greatly appreciated.

Mark
 
a example of me after save and reload the listview :

Dim adoCon As Connection
Dim adoCmd As Command
Dim adoRS As Recordset
Dim cmdtext As String
Dim lstItem As ListItem

lstTitles.ListItems.Clear
' here we are building the SQL statement based upon the filter drop down
If cmbFilter.Text = "Selecteer Categorie" Then
cmdtext = "SELECT id, title, codetype FROM source "
Else
cmdtext = "SELECT id, title, codetype FROM source WHERE codetype='" & StuffQuotes(cmbFilter.Text) & "' "
End If

'connect to the database and retrieve the code
Set adoCon = CreateObject("ADODB.Connection")
adoCon.Open gblConnectString
Set adoCmd = CreateObject("ADODB.Command")
adoCmd.ActiveConnection = adoCon
adoCon.CursorLocation = adUseClientBatch
adoCmd.CommandText = cmdtext
Set adoRS = adoCmd.Execute

'loop through the recordset and add each item to the listview
Do While Not adoRS.EOF
Set lstItem = lstTitles.ListItems.Add(, , adoRS("title"))
lstItem.Tag = adoRS("id") 'used for updating and deleting
lstItem.SubItems(1) = CStr(adoRS("codetype"))
adoRS.MoveNext
Loop
lstTitles_Click 'reset the list
'make sure to clean up after ourselves
adoRS.Close
Set adoRS = Nothing
Set adoCmd = Nothing
adoCon.Close
Set adoCon = Nothing
Exit Sub Eric De Decker
vbg.be@vbgroup.nl

Licence And Copy Protection AxtiveX
Source CodeBook for the programmer
 
Before reloading the TV, store .SelectedItem.Key. After reloading, set TV.Nodes(strKeyValue).Selected = True.

Remember to trap for errors. The previously selected node may not exist after reloading.

Craig Boland
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top