By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,359 Members | 1,495 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,359 IT Pros & Developers. It's quick & easy. TreeView won't display on my form?

P: 2
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
Share this Question
Share on Google+
3 Replies

Expert 100+
P: 1,017
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

P: 2
I've tried

tree.visible = true

neither have any effect....
Apr 15 '07 #3

Expert 100+
P: 1,017
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.