473,383 Members | 1,789 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,383 software developers and data experts.

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='checked'"
XPathDocument xpathDoc = new XPathDocument(m_configFile);
XPathNavigator xpathNav = xpathDoc.CreateNavigator();
XPathNodeIterator nodeIter = xpathNav.Select(@"/*[@status='checked']");

while(nodeIter.MoveNext())
{
xpath = nodeIter.CurrentPosition.ToString();
// 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.SelectedNode.blabla it randomly choses a node in treeView
control.

Aug 22 '06 #1
2 7407
Solution found:

string xpath = null;
XmlNode configNode = configDom.DocumentElement;
// collect selected nodes in node list
XmlNodeList nodeList =
configNode.SelectNodes(@"//*[@status='checked']");

//MessageBox.Show(Convert.ToString(nodeList.Count));

// loop through nodelist
foreach(XmlNode myNode in nodeList)
{
xpath = GetPathFromNode(myNode); // get node path
xpath = xpath + "\\" + myNode.InnerText.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.Nodes.Count; k++)
{
root = treeView1.Nodes[k]; // parent node

if(("\\"+root.FullPath.ToString()) == xpath) // compare paths
root.Checked=true; // set checkbox if node is found in tree view

// loop childs of root
for (int i=0; i<root.Nodes.Count; 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
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...
1
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...
4
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
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...
13
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...
4
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...
10
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...
0
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.