Solved

Kept diaplying TreeNode: ...

Posted on 2009-03-30
7
239 Views
Last Modified: 2012-05-06
Hi I'm trying to diaplay the Description stored in dr[3] after the last child node so it'll display something like this.
-A01
   -product
      -hardware
         - brand
              alpha: new brand
              beta: current leading brand

But when i generate the following code the last child node kept diaplaying this...
            TreeNode: alpha: new brand
            TreeNode: beta: current leading brand

Why is it so?I'd appreciated if help on the code is offered thanks.
foreach (DataRow dr in ordt.Rows)
                    {
                        nodeCheck = new TreeNode();
                        nodeCheck.Name = dr[0].ToString();                        
                        strText = dr[2].ToString();
                        strDesc = dr[3].ToString();
                        strList = strText.Split('.');
                        nodeCheck.Text = strList[strList.Length - 1];
                        if (dr[1] != DBNull.Value)
                        {
                            node = treeview1.Nodes.Find(dr[1].ToString(), true);
                                if (strList.Length == 5)
                                {
                                    nodeCheck.Text = nodeCheck + ": " + strDesc;
                                    node[0].Nodes.Add(nodeCheck);                                  
                                }
                                else
                                { node[0].Nodes.Add(nodeCheck); }
                        }                        
                        else
                        {
                            treeview1.Nodes.Add(nodeCheck);
                        } 
                        nodeCheck.Tag = dr[0].ToString();
                    }

Open in new window

0
Comment
Question by:csharp_learner
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 18

Expert Comment

by:philipjonathan
ID: 24025189
I suspect it's because of line 14. Try to change to:
nodeCheck.Text = strDesc;
0
 

Author Comment

by:csharp_learner
ID: 24025203
I changed it to
nodeCheck.Text = strDesc;
the last child node displayed the description w/o the "TreeNode: "
0
 
LVL 18

Expert Comment

by:philipjonathan
ID: 24025293
Isn't this what you want?
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

Author Comment

by:csharp_learner
ID: 24025341
Sorry for the confusion, what i wanted was
nodeCheck.Text = nodeCheck + ": " + strDesc;
Which is in my case "alpha: description"
But the Treeview kept showing "TreeNode: alpha: description"
0
 
LVL 18

Accepted Solution

by:
philipjonathan earned 400 total points
ID: 24025394
You mean without 'nodeCheck + ": " + ' you will not get 'alpha' shown?
nodeCheck.Text = nodeCheck.Text + ": " + strDesc;
0
 

Author Comment

by:csharp_learner
ID: 24025417
nodeCheck.Text = nodeCheck.Text + ": " + strDesc; worked.
Wow did'n know it was just the .text needed thanks.
Any reason for this happening?
0
 
LVL 18

Expert Comment

by:philipjonathan
ID: 24025439
nodeCheck is the object. If you show it on the screen, it will just show the object type, which is "TreeNode". What you need is the Text property of that object, which is "alpha".
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question