473,761 Members | 3,542 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("Emplo yees");

tvEmps.Nodes.Ad d(tnode);

tvEmps.ExpandAl l();

foreach(DataRow dro in Emp.Rows)

{

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

{

sEmpName = (string)dro["Employer_N ame"];

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

{

case 1:

tnIPCons = new TreeNode(sEmpNa me);

tnIPCons.Nodes. Add(sEmpName);

break;

case 2:

tnTemps = new TreeNode(sEmpNa me);

tnTemps.Nodes.A dd(sEmpName);

break;

case 3:

tnPenComp = new TreeNode(sEmpNa me);

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.A dd(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 2740

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

Similar topics

1
2135
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: Item Parent ------------------
4
3452
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 point me to documentation or samples that might help??? Thanks in advance meh
0
3442
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 try and figure out how to teach myself C# based on my old vb code but it's been more difficult than I first thought. I'm finding that it would be better if didn't know any previous programming language.
3
2568
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 most nodes will have only one parent, a few will have two parents. The Treeview which seems to me to lend itself to the Windows Explorer type of app could not possibly show one file as a leaf belonging to two different parent folders. You either...
5
3916
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) but only sometimes. Other times it appears behind the parent form and all that is visible is the last few characters of that row. Anyone know what might be causing this and how I can fix it? Thanks.
6
14201
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 my database apps its common place to tell the user that they are working on record x of xxx records I'm trying to provide the same functionality using the tree control. TIA meh
9
2099
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 C111 C1111 C1112 C1113
2
2407
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, deleted nodes, etc) I need to pass the treeview BACK to the original form. Is there an easy way to do this? Thanks, DC
1
2307
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 applet), with the ASP.Net TreeView. The tree resides in a frame, and when a link is clicked, has to change the HREF of another frame. Currently, the applet calls some javascript
0
9554
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9377
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
9989
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9925
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,...
1
7358
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
6640
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
5266
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...
1
3913
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 we have to send another system
3
2788
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.