This is a migrated thread and some comments may be shown as answers.

System.NullReferenceException

2 Answers 108 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Karl
Top achievements
Rank 1
Karl asked on 15 May 2010, 03:09 PM
I have a form in a WindowsApplication with just a RadTreeNode on it.


Imports System  
Imports Telerik.WinControls.UI  
 
Public Class Form1  
    Inherits Form  
    Private Sub Form1_Load(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Load  
        InitializeComponent()  
 
        Dim node As RadTreeNode = RadTreeView1.Nodes("Email Contacts").Nodes.Add("Bob Tony")  
        node.Selected = True 
        RadTreeView1.Nodes("Email Contacts").Nodes.Add("Sue Winchell")  
        RadTreeView1.Nodes("Email Contacts").Nodes.Add("Lui Sang")  
        RadTreeView1.Nodes("Lists").Nodes.Add("Priorities")  
        RadTreeView1.Nodes("Lists").Nodes.Add("Opportunities")  
        RadTreeView1.Nodes("Lists").Nodes.Add("Issues")  
    End Sub 
End Class 

This is from your example.
On reaching this line:
        Dim node As RadTreeNode = RadTreeView1.Nodes("Email Contacts").Nodes.Add("Bob Tony")  
I keep getting the error:
System.NullReferenceException was unhandled
  Message="Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt."

What's happening and how do I correct it?

Thanks in advance
Karl
 

2 Answers, 1 is accepted

Sort by
0
Karl
Top achievements
Rank 1
answered on 16 May 2010, 10:59 AM
Found it.
RadTreeView1.Nodes("Email Contacts"). doesn't exist - fist has to be added.
and
InitializeComponent()
was disturbing
thanks anyway
0
Victor
Telerik team
answered on 19 May 2010, 03:30 PM
Hello Karl,

It is great that you managed to find a solution.
Write again if you have other questions.

Sincerely yours,
Victor
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Treeview
Asked by
Karl
Top achievements
Rank 1
Answers by
Karl
Top achievements
Rank 1
Victor
Telerik team
Share this question
or