Hi,
The following populates the treeview from a dataset:
Public Sub load_categorys()
On Error GoTo err_handler
Dim indxRoot, indxCat, indxsubcat, indxa As Integer
Dim wknode As TreeNode
Treeview1.beginupdate ()
TreeView1.ShowLines() = True
nodedb1 = TreeView1.Nodes.Add(datasrc_file)
nodedb1.Tag = ("mdb")
indxRoot = nodedb1.Index
drest = dtest.Rows(0)
strb = drest.ItemArray(secnum)
For a = 0 To dtest.Rows.Count - 1
new_catagory:
If a > dtest.Rows.Count - 1 Then GoTo _end
drest = dtest.Rows(a)
stry = drest.ItemArray(secname)
strx = drest.ItemArray(secnum)
stra = strx & "_" & stry
strc = drest.ItemArray(secname)
nodex1 = nodedb1.Nodes.Add(strc)
nodex1.Tag = ("category") & "~" & stra
nodea1 = nodex1.Nodes.Add("item")
a = a + 1
drest = dtest.Rows(a)
x = 1
While Not x
If drest.ItemArray(secnum) = strb Then
a = a + 1
If a > dtest.Rows.Count - 1 Then GoTo _end
drest = dtest.Rows(a)
Else
strb = drest.ItemArray(secnum)
x = 0
GoTo new_catagory
End If
End While
Next a
_end:
nodedb1.Expand()
Treeview1.endupdate ()
Treeview1.reffresh ()
Exit Sub
err_handler:
Resume Next
End Sub
in the treeview1. afterselect event the node is processed and pricing info
is shown on the status bar.
in the before expand event the following code is also executed when a node
is double-tapped and the node.tag ="item":
Private Sub add_items()
mat_data_row = mat_data_table.NewRow()
mat_data_row(0) = DataGrid1.CurrentCell.RowNumber
If (_mfr <> 99) Then
If Not IsDBNull(datasrcstr(_mfr)) Then
mat_data_row(1) = datasrcstr(_mfr)
End If
End If
mat_data_table.Rows.Add(mat_data_row)
return_data_view()
'return_data_view() = 'mat_data_view = New DataView(mat_data_table)
'' Return mat_data_view
DataGrid1.DataSource = mat_data_view
Exit Sub
err_handler:
Resume Next
End Sub
once the add_item sub is run and the treeview data is changed and redrawn
the tree nodes become invisible. They are still there because I can scroll
through the nodes and see the pricing info on the status bar and
double-tapping on a node selects the item and adds it to the datagrid, but
the node names are invisible. I have tried commenting out
'mat_data_table.Rows.Add(mat_data_row)
'return_data_view()
and when the treeview is repopulated with new items they are visible, of
course with out those lines the item is not added to the datatable ,
dataview , or datagrid.
????
Sorry about the long length & different sized fonts in this post.
Thanks,
Ken