Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21854

how to fill treeview images using recordset dynamically

$
0
0
hello everyone... this is my first ever post here..

i'm having a treeview control and i want to add categories, products and images dynamically using recordset .. i m able to do for categories and products
but unable to work with images that i have stored in access database

Private Sub CreateCategoryNodes()

Set rs = New ADODB.Recordset

Dim strSQL As String
Dim nodX As Node

TreeView1.LineStyle = tvwRootLines
strSQL = "Select * from groups"
rs.Open strSQL, mycon, adOpenStatic, adLockOptimistic
' loop through the rows in the recordset
rs.MoveFirst
Do Until rs.EOF
Me.TreeView1.Nodes.Add Text:=rs!groupname, _
Key:="Cat=" & CStr(rs!groupID)
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
End Sub

Private Sub CreateProductNodes()
Set rs = New ADODB.Recordset

Dim strSQL As String
Dim nodX As Node

TreeView1.LineStyle = tvwRootLines

Dim img As ListImage

Dim i As Integer

strSQL = "Select * from products"
rs.Open strSQL, mycon, adOpenStatic, adLockOptimistic

' loop through the rows in the recordset
rs.MoveFirst
Do Until rs.EOF

For i = 0 To ImageList1.ListImages.Count
With ImageList1.ListImages
.Add , "Image1", rs!Image
End With
Next


TreeView1.Nodes.Add Relationship:=tvwChild, Relative:="Cat=" & CStr(rs!groupID), _
Text:=rs!ProductName, Key:="Prod=" & CStr(rs!productID), Image:=rs!Image
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
End Sub

Viewing all articles
Browse latest Browse all 21854

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>