We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Exception thrown when adding a node in TreeViewAdv

I have some (C#) code that looks something like this:

myderivedTreeViewAdv.Nodes.Clear()
DerivedTreeNodeAdv n = new DerivedTreeNodeAdv()
myderivedTreeViewAdv.Nodes.Add (n);

When I attempt to add the node I get an "Object not set to instance..." exception (stack trace below). Any ideas?

Mark

Stack Trace:
at
Syncfusion.Windows.Forms.Tools.TreeViewAdv.get_SelectedNode()
at Syncfusion.Windows.Forms.Tools.TreeNodeAdv.UpdateSelectedNodeIndexCache()
at Syncfusion.Windows.Forms.Tools.TreeNodeAdv.Nodes_CollectionChanged(Object sender, CollectionChangeEventArgs e)
at Syncfusion.Collections.ArrayListExt.OnCollectionChanged(CollectionChangeEventArgs args)
at Syncfusion.Windows.Forms.Tools.TreeNodeAdvCollection.OnCollectionChanged(CollectionChangeEventArgs args)
at Syncfusion.Collections.ArrayListExt.AddHandlers(Object item)
at Syncfusion.Collections.ArrayListExt.Add(Object value)
at Syncfusion.Windows.Forms.Tools.TreeNodeAdvCollection.Add(TreeNodeAdv node)

4 Replies

MA Mark Atkinson June 22, 2007 11:30 PM UTC

More on this:
I've tried a couple of things but I keep getting some odd exceptions ("Cannot access disposed object..." was another one) when trying to manipulate my TreeViewAdv object - typically when doing things like adding nodes or sorting.

The one thing I did notice is: I only get the exceptions when I close down the form that contains my TreeView and then reopen the form. After I've opened it the treeview's parent form a second time is when I start getting exceptions.

>I have some (C#) code that looks something like this:

myderivedTreeViewAdv.Nodes.Clear()
DerivedTreeNodeAdv n = new DerivedTreeNodeAdv()
myderivedTreeViewAdv.Nodes.Add (n);

When I attempt to add the node I get an "Object not set to instance..." exception (stack trace below). Any ideas?

Mark

Stack Trace:
at
Syncfusion.Windows.Forms.Tools.TreeViewAdv.get_SelectedNode()
at Syncfusion.Windows.Forms.Tools.TreeNodeAdv.UpdateSelectedNodeIndexCache()
at Syncfusion.Windows.Forms.Tools.TreeNodeAdv.Nodes_CollectionChanged(Object sender, CollectionChangeEventArgs e)
at Syncfusion.Collections.ArrayListExt.OnCollectionChanged(CollectionChangeEventArgs args)
at Syncfusion.Windows.Forms.Tools.TreeNodeAdvCollection.OnCollectionChanged(CollectionChangeEventArgs args)
at Syncfusion.Collections.ArrayListExt.AddHandlers(Object item)
at Syncfusion.Collections.ArrayListExt.Add(Object value)
at Syncfusion.Windows.Forms.Tools.TreeNodeAdvCollection.Add(TreeNodeAdv node)


JA JayaLakshmi Syncfusion Team June 25, 2007 05:26 AM UTC

Hi Mark,

Thank you for using Syncfusion products.

I am afraid that I could not able to reproduce this issue at my end.

Could you please send me the Customized TreeViewAdv class file and details to reproduce the issue. This will help us to analyze the issue further.

Please have a look at the below sample and let me know if I missed anything.

http://websamples.syncfusion.com/samples/Tools.Windows/F62846/main.htm

Regards,
Jaya


MA Mark Atkinson June 25, 2007 03:46 PM UTC

Hi Jaya,
I'll see if I can create a small app that repro's the problem but I suspect it's somewhere in my code.
The treeView's SelectedNode property always throws a 'null reference' exception when the treeView is disposed and then instantiated a second time.

>Hi Mark,

Thank you for using Syncfusion products.

I am afraid that I could not able to reproduce this issue at my end.

Could you please send me the Customized TreeViewAdv class file and details to reproduce the issue. This will help us to analyze the issue further.

Please have a look at the below sample and let me know if I missed anything.

http://websamples.syncfusion.com/samples/Tools.Windows/F62846/main.htm

Regards,
Jaya


MA Mark Atkinson June 25, 2007 04:30 PM UTC

I figured out my problem - which was definitely my problem and nothing to do with the TreeViewAdv control.
My issue is that I wasn't dealing with some event handlers properly when disposing the control.

Thanks for the prompt support all the same,
Mark

Loader.
Live Chat Icon For mobile
Up arrow icon