473,503 Members | 1,735 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Treeview Parent-Child

JJ
Hi All,

I am trying to Add nodes in code behind and am having
problems with the parent child relationships. I get a Use
of unassigned local variable error . I have the local
variables defined and in my switch statement I build the
parent Nodes and have children created off of them. What
am I doing wrong? Here is the code:

TreeNode tnode = new TreeNode("Employees");

tvEmps.Nodes.Add(tnode);

tvEmps.ExpandAll();

foreach(DataRow dro in Emp.Rows)

{

if (iEmpNum != (int)dro["Employer#"])

{

sEmpName = (string)dro["Employer_Name"];

switch ((int)dro["Employer#"])

{

case 1:

tnIPCons = new TreeNode(sEmpName);

tnIPCons.Nodes.Add(sEmpName);

break;

case 2:

tnTemps = new TreeNode(sEmpName);

tnTemps.Nodes.Add(sEmpName);

break;

case 3:

tnPenComp = new TreeNode(sEmpName);

tnPenComp.Nodes.Add(sEmpName);

break;

}

}

sEmpRec = dro["LastName"] + ", " + dro
["FirstName"] ;

switch ((int)dro["Employer#"])

{

case 1:

tnIPCons.Nodes.Add(sEmpRec); < ---
"ERROR Happens On these lines"

break;

case 2:

tnTemps.Nodes.Add(sEmpRec); < ---
"ERROR Happens On these lines"

break;

case 3:

tnPenComp.Nodes.Add(sEmpRec); < ---
"ERROR Happens On these lines"

break;

}
If this is not the right way to create Parent-Child
relationships, what is the right way?

Thanks,
JJ
Nov 15 '05 #1
0 2715

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

Similar topics

1
2096
by: Scott | last post by:
Hi everyone! My Access app. uses the ActiveX Treeview control to show a hierarchal structure of records. Each record has a name and a "parent" along with some other attibutes. For example: ...
4
3429
by: meh | last post by:
I need to be able to persist a treeView to disk. I would like to save the node text, tag, image and selected image. I have done this using vb but I cant seem to translate from vb to vc#. Can ne1...
0
3419
by: meh | last post by:
Still have not been able to convert this. More importently.....Is this sample going about it the right way??? tia meh Here is the vb code.........I keep looking at older vb.net projects to...
3
2551
by: Hazz | last post by:
I am just beginning to design a Treeview display (winforms) for wine regions. Problem. Some wine growing regions belong to two counties. Eg. Carneros is in both Napa and Sonoma Counties. Although...
5
3903
by: rh | last post by:
I created a user control that is made up of a TreeView and a VScrollBar. I set the TreeView.FullRowSelect = True and it works as expected (full row is visible, appears on top of everything else)...
6
14170
by: meh | last post by:
I can figure out the total number of nodes in a given tree but what I'd like to know is what is the Selected Nodes relationship to the entire tree i.e This is node n out of nnn nodes. In most of...
9
2087
by: Marina | last post by:
Hello! I have a database with some customers. Each one of them has 3 other customers under him etc. (something like an MLM system). Now, I want to create a treeview with this. Eg. C1 C11...
2
2392
by: dixiecanterbury | last post by:
I have a tree view on a form and I need to pass that treeview to another form keeping the state of the treeview (expanded nodes, etc). After the treeview has been manipulated (added nodes,...
1
2292
by: Dan Bass | last post by:
Using: ASP.Net 2.0 C# for code behind I'm slowly migrating a project into the .Net realm from ASP. One of the first things I've been asked to do is replace a tree navigation control (java...
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7076
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...
0
7274
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,...
0
7323
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5576
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,...
0
3151
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1507
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
732
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
377
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...

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.