Solved

Kept diaplying TreeNode: ...

Posted on 2009-03-30
7
233 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
  • 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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now