Results 1 to 2 of 2

Thread: [2005] TreeView Error??

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Posts
    182

    Thumbs up [2005] TreeView Error??

    I am trying to put a new treeview object into a menu that i downloaded from the internet. The menu is simply an outlook xp style one and you put a treeview in (like there inbox, outbox folders are) by:

    NavigateBar1.RelatedControl.Controls.Add(VARIABLEHERE)

    Below are the details of the error:
    System.NullReferenceException was unhandled
    Message="Object reference not set to an instance of an object."

    Source="PrepTrak"
    StackTrace:
    at PrepTrak.frmContainer.NavigateBarButton7_OnNavigateBarButtonSelected(NavigateBarButtonEventArgs e) in C:\Documents and Settings\ross\Desktop\Projects\PrepTrak\PrepTrak\frmContainer.vb:line 342
    at MT.WindowsUI.NavigationPane.NavigateBarButton.OnNavigateBarButtonSelectedEventHandler.Invoke(Navigat eBarButtonEventArgs e)
    at MT.WindowsUI.NavigationPane.NavigateBarButton.PerformClick()
    at MT.WindowsUI.NavigationPane.NavigateBarButton.OnMouseClick(MouseEventArgs e)
    at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
    at System.Windows.Forms.ContainerControl.WndProc(Message& m)
    at System.Windows.Forms.UserControl.WndProc(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
    at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoCompo nentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
    at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
    at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
    at System.Windows.Forms.Application.Run(ApplicationContext context)
    at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
    at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
    at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
    at PrepTrak.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
    at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
    at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
    at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
    at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
    at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
    at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    at System.Threading.ThreadHelper.ThreadStart()



    My Code is:
    Code:
            Dim f As New TreeView
            f.BeginUpdate()
            f.Nodes.Add("Parent")
            f.Nodes(0).Nodes.Add("Child 1")
            f.Nodes(0).Nodes.Add("Child 2")
            f.Nodes(0).Nodes(1).Nodes.Add("Grandchild")
            f.Nodes(0).Nodes(1).Nodes(0).Nodes.Add("Great Grandchild")
            f.EndUpdate()
    
            NavigateBar1.RelatedControl.Controls.Add(f)


    Any ideas on what the problem is??

    Cheers,
    Ross

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] TreeView Error??

    Either NavigateBar1 or, more likely, its RelatedControl property are Nothing.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width