469,898 Members | 2,248 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,898 developers. It's quick & easy.

VB.net TreeView won't display on my form?

Hi all - I'm kind of a newbie. I've been researching this problem for a couple of days now and my searches haven't really come up with any solutions - hopefully I'm just doing something silly and someone will be able to point it out to me!

I'm working with a dataset - which is separated from the rest of the program by a datamanager class I made.

My form calls the datamanager class function that will call the function in the dataset to create a treeview based on the relational data in my dataset.

When the treeview is returned to the original sub that call it in the form I can see that all of the nodes are still intact - but nothing displays on the form?

Here's the code under the form load event:
Dim i As Integer
For i = 0 To My.Application.DataManager.getSongTree().Nodes.Cou nt - 1
songTree.Nodes.Add(My.Application.DataManager.getS ongTree().Nodes(i))


Here's the code in my dataset:
Public Function gettreenode() As Windows.Forms.TreeView
Dim songTree As New Windows.Forms.TreeView
Dim nodeBand, nodeAlbum, nodeSong As New Windows.Forms.TreeNode
Dim rowBand, rowbandstoalbums, rowAlbum, rowSong As DataRow

For Each rowBand In Me.Tables("Bands").Rows

nodeBand = New Windows.Forms.TreeNode
nodeBand.Text = rowBand("BandName")
nodeBand.Tag = rowBand
nodeBand = songTree.Nodes.Add(rowBand("BandName"))
nodeBand.Tag = rowBand


For Each rowbandstoalbums In rowBand.GetChildRows("BandAlbumsBand")
rowAlbum = rowbandstoalbums.GetParentRow("AlbumBandsAlbums")

nodeAlbum = nodeBand.Nodes.Add(rowAlbum("AlbumTitle"))
nodeAlbum.Tag = rowAlbum

For Each rowSong In rowAlbum.GetChildRows("SongsAlbums")
nodeSong = nodeAlbum.Nodes.Add(rowSong("SongTitle"))
nodeSong.Tag = rowSong


Return songTree
End Function

Any ideas?
Apr 14 '07 #1
3 1612
1,017 Expert 512MB
I didn't test it but do you have something like tree.refresh property?

Sometimes Microsoft tree nodes disappear but it is enough to move scrollbar up and down for them to show up again.
Apr 15 '07 #2
I've tried

tree.visible = true

neither have any effect....
Apr 15 '07 #3
1,017 Expert 512MB
Step through your code again it looks to me that function gettreenode loads tree directly and you donít need to load it again in form load.

Use songTree.Show() before load it might help visualize on what is going on. You can remove this after itíll start working as intended.

With a loop below you duplicate each node that already loaded by a function. Maybe it is better just to pass a tree as an object to your function and load it as you do but once.

Expand|Select|Wrap|Line Numbers
  1. For i = 0 To My.Application.DataManager.getSongTree().Nodes.Count - 1
  2.    songTree.Nodes.Add(My.Application.DataManager.getSongTree().Nodes(i))
  3. Next
Maybe I am wrong, it is hard to judge without testing.

Good Luck.
Apr 15 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

42 posts views Thread by lauren quantrell | last post: by
reply views Thread by BjŲrn Bengtsson | last post: by
2 posts views Thread by Irishmaninusa | last post: by
6 posts views Thread by Jarod_24 | last post: by
5 posts views Thread by david | last post: by
9 posts views Thread by auntiejack56 | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.