TreeNode.Remove(Boolean notify) exception

B

Boni

Dear all,
I have a tree node inherited from TreeNode class. Sometimes when I call
Nodes.Clear() I get following exception.
I use .NET 2.0.50727.
Seems to be MS bug?
Any ideas?
Thanks
Boni

System.NullReferenceException: Object reference not set to an instance of an
object.
at System.Windows.Forms.TreeNode.Remove(Boolean notify)
at System.Windows.Forms.TreeNode.Clear()
at System.Windows.Forms.TreeNodeCollection.Clear()
 
C

Chris

Boni said:
Dear all,
I have a tree node inherited from TreeNode class. Sometimes when I call
Nodes.Clear() I get following exception.
I use .NET 2.0.50727.
Seems to be MS bug?
Any ideas?
Thanks
Boni

System.NullReferenceException: Object reference not set to an instance of an
object.
at System.Windows.Forms.TreeNode.Remove(Boolean notify)
at System.Windows.Forms.TreeNode.Clear()
at System.Windows.Forms.TreeNodeCollection.Clear()

It is telling you that "Nodes" is set to nothing when you are calling Clear.

Try this:

if Nodes isnot nothing Nodes.Clear
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top