| | | 
Forum God
       
Group: Forum Members Last Login: 4/13/2009 1:04:38 PM Posts: 910, Visits: 5,436 |
| Does anyone know or a REAL tutorial on Treeview. Not loading ado, xml, directories, etc. I mean one that explains the properties of the Treeview control. The above is about all I can find on the internet.
What I am trying to do is add a node to the treeview in a predetermined location. I then want to add two sub-nodes to the one just entered.
Dim oNode As New TreeNode oNode.Name = "Level1" TreeView1.Nodes.Add(oNode) TreeView1.SelectedNode.Name = oNode.Name ==> Getting error here TreeView1.Nodes.Add("Level1a") TreeView1.Nodes.Add("level1b") oNode = Nothing
The error is "NullReferencException was unhandeled." and "Object reference not set to an instance of an object."
Any tutorial on this subject would be greatly appreciated.
WayneI know enough to be dangerious. It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living. |
| | | | Forum God
       
Group: Forum Members Last Login: Today @ 10:38:55 AM Posts: 1,000, Visits: 7,782 |
| I don't know of any tutorials and I'm just shooting in the dark here but I would try TreeView1.SelectedNode = oNode or Set TreeView1.SelectedNode = oNode |
| | | | 
Forum God
       
Group: Forum Members Last Login: 4/13/2009 1:04:38 PM Posts: 910, Visits: 5,436 |
| Thanks Mark but it put all them on the same level. I used: oNode.Name = "Level1" oNode.Text = "Level1" TreeView1.Nodes.Add(oNode) TreeView1.SelectedNode = oNode oNode = New TreeNode oNode.Name = "Level1b" oNode.Text = "Level1b" TreeView1.Nodes.Add(oNode) oNode = New TreeNode oNode.Name = "Level1a" oNode.Text = "Level1a" TreeView1.Nodes.Add(oNode)
I appreciate it though.
WayneI know enough to be dangerious. It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living. |
| | | | Forum God
       
Group: Forum Members Last Login: 3/13/2006 2:34:13 AM Posts: 794, Visits: 338 |
| Private Sub button2_Click(sender As Object, _ e As System.EventArgs) Handles button2.Click Dim oNode As New TreeNode oNode.Text = "My Node" TreeView1.Nodes.Add(oNode) oNode.Nodes.Add("") end sub
Private Sub button1_Click(sender As Object, _ e As System.EventArgs) Handles button1.Click If treeView1.SelectedNode.IsExpanded Then treeView1.SelectedNode.Collapse() MessageBox.Show(treeView1.SelectedNode.Text & _ " tree node collapsed.") Else treeView1.SelectedNode.Expand() MessageBox.Show(treeView1.SelectedNode.Text & _ " tree node expanded.") End If End Sub
I haven't done anything w/treeviews yet, but I've pieced the code from yours and msdn and here's a link for taking further steps: http://www.vbdotnetheaven.com/Code/Jun2003/2083.asp
also, i'm thinking that it's not really neccessary to get Name properties, just use the text properties or hide info in the tag of node you add, then reference that node's tag or text from treevies selectednode event.
prob didn't help much. good luck 
|
| |
|
|