?
Solved

Kept diaplying TreeNode: ...

Posted on 2009-03-30
7
Medium Priority
?
242 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 1600 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

777 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