473,804 Members | 3,063 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting single treeview node by path

heyho, guys! here's another question for you now:

i built an iterator to get all the nodes with a certain attribute in an

xml dom. it all looks like this (i'm using .NET framework 1.1)
string xpath;
// iterate over all xmlnodes with attribute "status='checke d'"
XPathDocument xpathDoc = new XPathDocument(m _configFile);
XPathNavigator xpathNav = xpathDoc.Create Navigator();
XPathNodeIterat or nodeIter = xpathNav.Select (@"/*[@status='checke d']");

while(nodeIter. MoveNext())
{
xpath = nodeIter.Curren tPosition.ToStr ing();
// here i want to address an treeview node with the xpath to
set its
checkbox

}
so what i want to know is: how can i address a treeview node by it's
path? for if i go like
treeView1.Selec tedNode.blabla it randomly choses a node in treeView
control.

Aug 22 '06 #1
2 7445
Solution found:

string xpath = null;
XmlNode configNode = configDom.Docum entElement;
// collect selected nodes in node list
XmlNodeList nodeList =
configNode.Sele ctNodes(@"//*[@status='checke d']");

//MessageBox.Show (Convert.ToStri ng(nodeList.Cou nt));

// loop through nodelist
foreach(XmlNode myNode in nodeList)
{
xpath = GetPathFromNode (myNode); // get node path
xpath = xpath + "\\" + myNode.InnerTex t.ToString(); // complete path
string
}

Aug 23 '06 #2
oh, and of course the following:

//Loop through the Parent Nodes
for(int k=0; k<treeView1.Nod es.Count; k++)
{
root = treeView1.Nodes[k]; // parent node

if(("\\"+root.F ullPath.ToStrin g()) == xpath) // compare paths
root.Checked=tr ue; // set checkbox if node is found in tree view

// loop childs of root
for (int i=0; i<root.Nodes.Co unt; i++)
VisitChildNodes (root.Nodes[i], xpath);
}

Aug 23 '06 #3

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

Similar topics

2
1688
by: ThunderMusic | last post by:
Hi, while I'm searching into a treeview to find a specific node, I find the code duplicating treeview nodes I just can't figure out what's causing this behavior, maybe some of you already encountered this problem. Can someone help please? Here is the code of the functions causing this problem Thanks
1
1425
by: Ferrari, Eduardo | last post by:
Hi Everybody I have a string that contains part of a directory structure that will be created in the future. I want to display this future tree on a treeview for the user see and then approve it. I was able to populate the first level of the tree, but I'll need some information to how populate the child levels of the tree. For example, if I have the directory (not created on the OS yet):
4
7602
by: Ian Powell | last post by:
Hi I've got objects in an sorted ArrayList like: P:\ P:\\DOCS P:\\i386 P:\\i386\ASMS P:\\i386\ASMS\1000 P:\\i386\ASMS\1000\MSFT
4
10142
by: Karim El Jed | last post by:
Hi, I'm trying to expand a special Node of my TreeView from Codebehind. I have a TreeView on a page for navigating to another site. On the other tsite here is the same TreeView more precisely a new TreeView with the same nodes ;) So I would like to keep the expanding state of the first Tree for the second one on the next page. At least the last selected node (path will be saved in query string) should be expanded.
13
9067
by: André Nogueira | last post by:
Hi there. I know you can view a node's fullpath property, but is it posible to select a node using its path? Like, tell the treeview that the node that should be selected is the node with the path "Users\Administrators\John Doe"? Thank you in advance! Andre Nogueira
4
9425
by: Andrew Robinson | last post by:
I am using a TreeView to perform navigation and have a few nodes that need to generate a popup menu. For this, I use the SelectedNodeChanged event and then add the relevant "window.open" script to the page using the ClientScript.RegisterStartupScript method. This seems to work fine, but if the user clicks on the same node twice, the event doesn't fire a second time. I assume this is by design as the Node Selection hasn't changed, but...
10
2371
by: p3t3r | last post by:
I have a treeview sourced from a SiteMap. I want to use 2 different CSS styles for the root level nodes. The topmost root node should not have a top border, all the other root nodes should have a top border. Is it possible to have more than 1 style at the same level (parent node) when using a SiteMap? I want it to appear something like this and I can only find a way to either have the border on all root nodes or none at all. In...
0
1782
by: Treeview Trouble | last post by:
I have an application where there are two radio buttons each of which populates a treeview control with a directory structure. Each radio button corresponds to a different directory which may or may not have some subdirectories with the same name. I am not having any problems populating the treeview with the corresponding directory structure when switching between radio buttons. In the treeview's AfterSelect event, I take the path from...
0
12794
by: jiing | last post by:
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.
0
9711
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
9591
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10594
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
10343
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
10331
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
10087
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6861
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();...
1
4306
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
3001
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.