Passing an array to Tag property

G

Guest

Hi,

I'm using the tag property of the Treenode object to store an string array
containing some values. I can assign it to the Tag but when I try to retrieve
values from it I get an error: "Object reference not set to object"

This is what i'm doing below:

// retrieve the array from the treenode tag property
memberInfo = (string[])tn.Tag;

// Try to display the first element. Get error here.
Debug.Assert(false,memberInfo[0]);

What is causing this error?
Any ideas are appreciated

Thanks very much in advance
Ant
 
T

TheSteph

Your StringArray seems to be empty.... or no StringArray are assigned to the
node "tn"...
You should give us the code where you assign the StringArray to the Tag
property....

Steph.
 
G

Guest

Thanks for the reply TheSteph,

This is how I'm filling the array & assigning it to the Tag property:

// Create & fill array
string[] memberDetails = { familyMember.MemberName,
familyMember.Gender, familyMember.MaritalStatus };

// Assign array to Tag property
nodeMember.Tag = memberDetails;


I have also done the same thing using a struct instead of an array but I get
the same error.

Hope this helps you help me ;)

Thanks for your time on this
Ant





TheSteph said:
Your StringArray seems to be empty.... or no StringArray are assigned to the
node "tn"...
You should give us the code where you assign the StringArray to the Tag
property....

Steph.


Ant said:
Hi,

I'm using the tag property of the Treenode object to store an string array
containing some values. I can assign it to the Tag but when I try to retrieve
values from it I get an error: "Object reference not set to object"

This is what i'm doing below:

// retrieve the array from the treenode tag property
memberInfo = (string[])tn.Tag;

// Try to display the first element. Get error here.
Debug.Assert(false,memberInfo[0]);

What is causing this error?
Any ideas are appreciated

Thanks very much in advance
Ant
 
G

Guest

Hi The Steph,

You were correct. As the loop iterated through, some elements were empty.

Thanks very much for your help.

Ant

TheSteph said:
Your StringArray seems to be empty.... or no StringArray are assigned to the
node "tn"...
You should give us the code where you assign the StringArray to the Tag
property....

Steph.


Ant said:
Hi,

I'm using the tag property of the Treenode object to store an string array
containing some values. I can assign it to the Tag but when I try to retrieve
values from it I get an error: "Object reference not set to object"

This is what i'm doing below:

// retrieve the array from the treenode tag property
memberInfo = (string[])tn.Tag;

// Try to display the first element. Get error here.
Debug.Assert(false,memberInfo[0]);

What is causing this error?
Any ideas are appreciated

Thanks very much in advance
Ant
 

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