|
-
Feb 22nd, 2008, 06:52 PM
#1
Thread Starter
Junior Member
Help NullReferenceException was unhandled when coding with treeview
I am new to vb.net 2005 and am desperate in need of solution as I faced error on the following codes.
Public Class Form1
Private PreviousTab As TabControl
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load
ListNodes(TreeView1.Nodes(0))
With TreeView1.Nodes.Item("AdminMenu")
.Nodes.Item("AddCustomer").Tag = TabAddCust
.Nodes.Item("DeleteCust").Tag = TabDeleteCust
End With
End Sub
Private Sub ListNodes(ByVal StartNode As TreeNode)
Debug.WriteLine(StartNode.Name)
For Each n As TreeNode In StartNode.Nodes
ListNodes(n)
Next
End Sub
Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
If PreviousTab IsNot Nothing Then
PreviousTab.Visible = False
End If
If e.Node.Tag IsNot Nothing Then
Dim ActiveTab As TabControl = CType(e.Node.Tag, TabControl)
ActiveTab.Visible = True
ActiveTab.Dock = DockStyle.Fill
PreviousTab = ActiveTab
End If
End Sub
When I run the program two lines of the code face error message of NullReferenceException was unhandled.
.Nodes.Item("AddCustomer").Tag = TabAddCust
.Nodes.Item("DeleteCust").Tag = TabDeleteCust
I am clueless on how to solve this.
Please help me!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|