invisible treeview nodes

  • Thread starter Kenneth Windish
  • Start date
K

Kenneth Windish

Hi,

I have an application that loads data into a treeview. Different data is
reloaded as needed and the treeview nodes are rebuilt wi th the new data.
All works well until the following command is processed -

** mat_data_table.rows.add(mat_data_row) **

once the data row is added to the data table and the treeview is redrawn
with new data the nodes are invisible. I can touch the screen and the nodes
are processed and results are shown on the status bar, so I know the nodes
are there they are just invisible.

Any one have any ideas?

TIA
Ken
 
D

Daniel Moth

Other than the obvious of the node's text being empty or full of blanks I
cannot think of anything. Can you post a complete repro or at least the code
that populates the tree?

Cheers
Daniel
 
K

Kenneth Windish

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
 
D

Daniel Moth

Sorry Ken, there is too much going on in that code and too many
methods/variables used that are not present. I pasted your code in a new
project and with some amendments could narrow it down to 71 errors but that
is still too many for me to figure out what you are doing.

I suggest you start a new project adding a bit at a time in order to end up
with a *small* repro sample that you can post back (although you will
probably figure it out yourself if you take that approach).

May I also strongly recommend you get rid of (refactor) your GoTos and your
On Error code. The former is just bad news and the latter should be replaced
with try..catch.

Cheers
Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top