The following code that I use to populate a treeview control
gives me an imagelist error.
The error is "Image List must be initialized before it can be used." This has to be easy, so how is it done?Code:Private Sub RefreshNodes() 'refresh TreeView On Error GoTo Database_Error Dim MyNode As Node tvUsers.Nodes.Clear Set MyNode = tvUsers.Nodes.Add(, , "Users", "Users") Adodc1.Recordset.MoveFirst Do Until Adodc1.Recordset.EOF 'establish node with USER as both key and text 'this is where the image list error occurs Set MyNode = tvUsuarios.Nodes.Add("Users", tvwChild, Adodc1.Recordset.Fields("USER").Value, Adodc1.Recordset.Fields("USER").Value, imgLTreeView, 0) MyNode.EnsureVisible Adodc1.Recordset.MoveNext Loop ShowUserData (tvUsers.Nodes(2).Text) Exit Sub Database_Error: Select Case Err.Number Case 2147217885 'reference to a record that does not exist Resume Next Case Else MsgBox ErrFunction(Err.Description, Err.Number, Err.Source, Me.Name, Screen.ActiveControl.Name), vbCritical End Select End Sub




Reply With Quote