473,394 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How to find node in TreeView by using string(the same as Node.Text) ?

Hi all,

I want to use sting(the same as Node.Text) to judge if a node exists
in TreeView.
I've tried several ways, but seems all failed.

could anybody help me?

Thanks in advance.
//My TreeView is defined to has depth =3 only.
//My code snippet as follows:
// path ="rootNode: parentNode: childNode" // path is something like
this
//try to use the path we already have to judge if a node already
exists in treeveiw

TreeNode rootNode = new TreeNode();
TreeNode parentNode = new TreeNode();
TreeNode childNode = new TreeNode();
for(int depth = 0 ; depth < path.Length -1; depth+
+)
{
string nodeOfTreeView = path[depth]; //to get the
rootNode, if depth ==0
if ( nodeOfTreeView != null) //to prevent some path
only has depth =2 or 1
{
if (depth == 0) //deal with rootNode
{
rootNode.Text = nodeOfTreeView;
rootNode.Value = nodeOfTreeView;
rootNode.NavigateUrl = @"./
ShowComponentDetails.aspx?Name=" + nodeOfTreeView;
if
(TreeViewOfPath.FindNode(rootNode.ValuePath) != null) //is this
corrent??
{
// Indicate that the node was found.
showMsg("The specified node (" +
rootNode.ValuePath + ") was found.");
}
else
{
// Indicate that the node is not in the
TreeView control.
showMsg("The specified node (" +
nodeOfTreeView + ") is not in this TreeView control.");
showMsg("new rootNode =" +
rootNode.Value);

TreeViewOfPath.Nodes.Add(rootNode);
}
}
else if (depth == 1)
{
parentNode.Text = nodeOfTreeView;
parentNode.Value = nodeOfTreeView;
parentNode.NavigateUrl = @"./
ShowComponentDetails.aspx?Name=" + parentNode;

if (isNodeExistInTreeView(parentNode.Text))
{
// Indicate that the node was found.
showMsg("The specified node (" +
parentNode.ValuePath + ") was found.");
}
else
{
// Indicate that the node is not in the
TreeView control.
showMsg("The specified node (" +
nodeOfTreeView + ") is not in this TreeView control.");
showMsg(" rootNode =" + rootNode.Text);
showMsg("new parentNode =" +
parentNode.Value);

rootNode.ChildNodes.Add(parentNode);
}

}
else if(depth == 2)
{
childNode.Text = nodeOfTreeView;
childNode.Value = nodeOfTreeView;
childNode.NavigateUrl = @"./
ShowComponentDetails.aspx?Name=" + childNode;
if (isNodeExistInTreeView(childNode.Text))
{
// Indicate that the node was found.
showMsg("The specified node (" +
childNode.ValuePath + ") was found.");
}
else
{
// Indicate that the node is not in the
TreeView control.
showMsg("The specified node (" +
nodeOfTreeView + ") is not in this TreeView control.");
showMsg(" parentNode =" +
parentNode.Text);
showMsg("new childNode =" +
childNode.Text);

parentNode.ChildNodes.Add(childNode);
}
}
}
//add the treeview we generated to page's form1

Page.FindControl("Form1").Controls.Add(TreeViewOfP ath);
}
*/

Apr 27 '07 #1
0 12764

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

Similar topics

3
by: Michael Hill | last post by:
I am trying to get all the "polyline" tags and then find the parent node above it so I can transform it. var poly = svgDocument.getElementsByTagName("polyline"); for ( var i=0; i < poly.length;...
2
by: Raed Sawalha | last post by:
I have following XML: How can I find the depth of XML? in other word max level of the XML <Root> ----- level 0 <Name>----- level 1 <FirstName>name</FirstName> ---- level 2...
1
by: jcabc | last post by:
I have a text string which has multiple values seperated by commas. My goal is to find the postion of the 4th comma and then read the text after that comma until the next comma using VBA. Ex. ...
7
by: Yongsub Eric Shin | last post by:
Hi. I'm just a beginner in ASP.Net. I started writing codes and I keep on getting this Runtime Error page, where it says "Description: An application error occurred on the server. The current...
13
by: Steve Edwards | last post by:
Hi, Given a map: typedef map<long, string, greater<long> > mapOfFreq; Is there a quicker way to find the rank (i.e. index) of the elememt that has the long value of x? At the moment I'm...
9
by: anunaygupta | last post by:
Hello all, I have a data structures problem. Assume there are 2 linked lists L1 and L2. They merge into some node. L1 1->2->3->4->5->6 / L2 8->7->9->/ L1 and L2 merge in node with value...
3
by: Martin Z | last post by:
Hi, I have an application that involves sending a lot of XML data to various places. The problem is that once in a while, I just want the XML document as a string (for example, sending to a...
1
by: prasiddha | last post by:
hi, i want to find the presence of a node and if present, i want to list the items or values in it. can u please help in this??? i/p may be, <A> <A1> <A2>ABC</A2> <A3>234</A3> </A1> </A>
5
by: Johny | last post by:
How can I find the first space using regex? For example I have text Text=' This is a sample ' The last space I can remove by Text=re.sub(r"\s(?!\w)",'',Text) but I do not know how to...
2
by: slizorn | last post by:
hi guys, i need to make a tree traversal algorithm that would help me search the tree.. creating a method to search a tree to find the position of node and to return its pointer value basically i...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.