473,761 Members | 2,384 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Naviga teUrl = @"./
ShowComponentDe tails.aspx?Name =" + nodeOfTreeView;
if
(TreeViewOfPath .FindNode(rootN ode.ValuePath) != null) //is this
corrent??
{
// Indicate that the node was found.
showMsg("The specified node (" +
rootNode.ValueP ath + ") 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(rootN ode);
}
}
else if (depth == 1)
{
parentNode.Text = nodeOfTreeView;
parentNode.Valu e = nodeOfTreeView;
parentNode.Navi gateUrl = @"./
ShowComponentDe tails.aspx?Name =" + parentNode;

if (isNodeExistInT reeView(parentN ode.Text))
{
// Indicate that the node was found.
showMsg("The specified node (" +
parentNode.Valu ePath + ") 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.Valu e);

rootNode.ChildN odes.Add(parent Node);
}

}
else if(depth == 2)
{
childNode.Text = nodeOfTreeView;
childNode.Value = nodeOfTreeView;
childNode.Navig ateUrl = @"./
ShowComponentDe tails.aspx?Name =" + childNode;
if (isNodeExistInT reeView(childNo de.Text))
{
// Indicate that the node was found.
showMsg("The specified node (" +
childNode.Value Path + ") 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.Chil dNodes.Add(chil dNode);
}
}
}
//add the treeview we generated to page's form1

Page.FindContro l("Form1").Cont rols.Add(TreeVi ewOfPath);
}
*/

Apr 27 '07 #1
0 12790

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

Similar topics

3
1932
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; i++ ) { myobj=poly.parentNode(i); alert(i + myobj); }
2
8446
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 <LasName>lname</LastName> <MiddleName>mName<MiddleName> </Name>
1
4964
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. One, Two, Three, Four, Five, Six Valued wanted: " Five" Is there any way to do this??
7
2861
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 custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
13
5052
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 iterating through the map and keeping count of when I hit it.
9
3037
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 5. We need to return the pointer to
3
2491
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 typed dataset tableadaptor). In that case, I have a problem: what encoding do I use to conver the byte (or memorystream) into a string? The encoding is in the file, of course, like any XML file, but how do I find out which? I tried using an...
1
1450
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
3489
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 remove the first space. Can anyone help?
2
2661
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 need to read in a text file... shown below H H,E,L E,B,F B,A,C A,null,null
0
9522
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
10111
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9948
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
9902
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,...
0
6603
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
5215
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...
0
5364
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3866
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
2738
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.