|
-
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!!!
-
Feb 22nd, 2008, 07:44 PM
#2
Re: Help NullReferenceException was unhandled when coding with treeview
You need to verify that TreeView1 contains a node with the key "AdminMenu" that in turn holds two nodes with the keys "AddCustomer" and "DeleteCust".
Furthermore, you should post all your VB.Net questions in the VB.Net forum, a moderator will probably move this thread as soon as possible.
And you should wrap your code in [HIGHLIGHT=VB.Net][/HIGHLIGHT] tags.
-
Feb 22nd, 2008, 07:44 PM
#3
Re: Help NullReferenceException was unhandled when coding with treeview
This is the Feedback forum and you need to post that in VB.net.
-
Feb 22nd, 2008, 08:01 PM
#4
Re: Help NullReferenceException was unhandled when coding with treeview
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 22nd, 2008, 09:32 PM
#5
Thread Starter
Junior Member
Re: Help NullReferenceException was unhandled when coding with treeview
Thanks for the answer.
Could you give me some tips on how to verify the nodes given the Admin Menu node as the root node and the child node is AddCustomer? I need sample coding to understand because I just started learning visual basic.net less than a month.
So sorry for using the wrong forum I think being awake for too long figuring out solution makes me blur .
-
Apr 27th, 2011, 07:48 AM
#6
New Member
Re: Help NullReferenceException was unhandled when coding with treeview
please help me, i have big problem in my solutions projects in visual studio 2005
System.NullReferenceException was unhandled
Message="Object reference not set to an instance of an object."
Source="MBSControls"
StackTrace:
at MBSControls.ListViewXTC.InitializeList(Object items) in C:\Projects\TimeSheet\MBSControls\ListViewXTC.cs:line 208
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
|