473,666 Members | 2,075 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing an array to Tag property

Ant
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(fa lse,memberInfo[0]);

What is causing this error?
Any ideas are appreciated

Thanks very much in advance
Ant


Jul 11 '06 #1
3 6131
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" <An*@discussion s.microsoft.com wrote in message
news:B9******** *************** ***********@mic rosoft.com...
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(fa lse,memberInfo[0]);

What is causing this error?
Any ideas are appreciated

Thanks very much in advance
Ant


Jul 11 '06 #2
Ant
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.Me mberName,
familyMember.Ge nder, familyMember.Ma ritalStatus };

// 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" wrote:
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" <An*@discussion s.microsoft.com wrote in message
news:B9******** *************** ***********@mic rosoft.com...
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(fa lse,memberInfo[0]);

What is causing this error?
Any ideas are appreciated

Thanks very much in advance
Ant




Jul 12 '06 #3
Ant
Hi The Steph,

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

Thanks very much for your help.

Ant

"TheSteph" wrote:
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" <An*@discussion s.microsoft.com wrote in message
news:B9******** *************** ***********@mic rosoft.com...
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(fa lse,memberInfo[0]);

What is causing this error?
Any ideas are appreciated

Thanks very much in advance
Ant




Jul 12 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5302
by: Ryan Malone | last post by:
Passing Dictionary object byref Ive created an ASP class that uses a dictionary object which is filled from a recordset. It passes the object to the propterty of another ASP class byref: Public Property Let dicReplaceVars(byref vdicReplaceVars) set p_ReplaceVars = vdicReplaceVars End Property
3
14929
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) { document.images.src = eval("mt" +menu+ ".src") } alert("imgOff_hidemenu"); hideMenu=setTimeout('Hide(menu,num)',500);
58
10122
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of code... TCHAR myArray; DoStuff(myArray);
2
1925
by: craigkenisston | last post by:
Hi, I created an array of objects like this : object Values = {myObject.myprop, otherobject.otherprop, thirdobject.xprop}; Then I pass it to a method. and I get the values filled in that method. I can debug the method and values are being assigned. But when I am in the calling procedure I no longer see the values, I
6
5578
by: ged | last post by:
Hi, i am a oo (c#) programmer, and have not used javascript for a while and i cant work out how javascript manages its references. Object References work for simple stuff, but once i have an object collection and stanrd using it it starts to fall apart. Clearly there is something about javascript's usage of passing "By ref" that i am not getting. i have had a look on the web and found some examples, but i cant see why my code does not...
1
1644
by: kmercer46 | last post by:
have a class that contains an array and i would like to access the individual array elements in a form. I understand that VB.net does not allow the array to be public and i think i need to pass it as a parameter? What i would like is on the form, to have a button when clicked, it checks the elements against each other to see if they are different (they are integers). I have looked on the net for some guidance on this but not found...
9
3784
by: Greger | last post by:
Hi, I am building an architecture that passes my custom objects to and from webservices. (Our internal architecture requires me to use webservices to any suggestion to use other remoting techniques are not feasible) The question is; Given that I have a Person object with a private set for id. What is the recommended approac in passing that object to the web service
7
5383
by: David Lowndes | last post by:
The following example illustrates something that's taken me a while to suss out (debugging someone else's code :( )... The crux is that the code compiles cleanly at W4, and the issue is that I'm passing a property by reference to a function that's trying to modify it. Needless to say the result isn't what was intended as the property doesn't get modified.
1
3491
by: aeshiels | last post by:
Hopefully I have the correct newsgroup for this question. I've developed a very simple COM server in C++ as im trying to learn COM. The COM server has an array of IUnknown interfaces (MyArray) where im allowing the user to store COM objects (derived from IUnknown) via get/put properties. I have a created a COM object which is derived from IUnknown but when i come to add the object to my array from C# i get a com exception : "Unable to...
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8871
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8552
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7387
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1776
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.