Beginner and trying to get the tag value of a treeview.selectednod

K

KCBTDev

I am trying to do this line of code:
txtBxMessageBody.Text = ".\\ " + treeView1.SelectedNode.Tag.ToString();

I am getting an error back. It is something pretty simple but I can't
figure it out.
The error is: System.NullReferenceException: Object reference not set to an
instance of an object at myMethod

This is the only line of code in the method and when I only add a string to
the .Text value it runs fine.

Any ideas?
 
R

ruben

either the tree view do not has a node selected (treeView1.SelectedNode ==
null)
or the tag property is not set (treeView1.SelectedNode.Tag == null)
 

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