473,372 Members | 921 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,372 software developers and data experts.

Expanding a tree view with a path

I have a tree view with a root, 3 noodes(1,2,3) each having one sub node.

I drill down to a node.

I get the path by saying treeView1.selectedNode.fullpath and assign it to a
variable.

If I redraw the tree, or close it up and want to expand the same node again,
can i do this via the path?

Thank you kindly.
Feb 3 '06 #1
4 11931
James,

This seems a little more complicated than it should have to be.

Basically, what you have to do is parse apart the full path, delimited
by the value in the PathSeparator property. Then, you would take Nodes
property on the TreeView, and look for the first key (through the IndexOfKey
method). Then, you take that node, and look for the next key in the
collection of TreeNode instances returned from Node.

Once you have the final node, you can call the EnsureVisible method on
the last node, and then it will expose the node in the tree.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"James L" <Ja****@discussions.microsoft.com> wrote in message
news:1F**********************************@microsof t.com...
I have a tree view with a root, 3 noodes(1,2,3) each having one sub node.

I drill down to a node.

I get the path by saying treeView1.selectedNode.fullpath and assign it to
a
variable.

If I redraw the tree, or close it up and want to expand the same node
again,
can i do this via the path?

Thank you kindly.

Feb 3 '06 #2
I cannot seem to see an index of key mathod or an ensure visible method.
I have this so far.

string path = treeView1.SelectedNode.FullPath;
string delimit = @"\";
char [] delimiter = delimit.ToCharArray();
string [] split = null;

split = path.Split( delimiter );

int treeNodeIndex;
TreeNode t = new TreeNode( split[0].ToString());
treeNodeIndex= treeView1.Nodes[0].Nodes.IndexOf( t );

thanks
"Nicholas Paldino [.NET/C# MVP]" wrote:
James,

This seems a little more complicated than it should have to be.

Basically, what you have to do is parse apart the full path, delimited
by the value in the PathSeparator property. Then, you would take Nodes
property on the TreeView, and look for the first key (through the IndexOfKey
method). Then, you take that node, and look for the next key in the
collection of TreeNode instances returned from Node.

Once you have the final node, you can call the EnsureVisible method on
the last node, and then it will expose the node in the tree.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"James L" <Ja****@discussions.microsoft.com> wrote in message
news:1F**********************************@microsof t.com...
I have a tree view with a root, 3 noodes(1,2,3) each having one sub node.

I drill down to a node.

I get the path by saying treeView1.selectedNode.fullpath and assign it to
a
variable.

If I redraw the tree, or close it up and want to expand the same node
again,
can i do this via the path?

Thank you kindly.


Feb 3 '06 #3
James,

You have to call the IndexOfKey method, passing the current element in
split that you are looking at.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"James L" <Ja****@discussions.microsoft.com> wrote in message
news:96**********************************@microsof t.com...
I cannot seem to see an index of key mathod or an ensure visible method.
I have this so far.

string path = treeView1.SelectedNode.FullPath;
string delimit = @"\";
char [] delimiter = delimit.ToCharArray();
string [] split = null;

split = path.Split( delimiter );

int treeNodeIndex;
TreeNode t = new TreeNode( split[0].ToString());
treeNodeIndex= treeView1.Nodes[0].Nodes.IndexOf( t );

thanks
"Nicholas Paldino [.NET/C# MVP]" wrote:
James,

This seems a little more complicated than it should have to be.

Basically, what you have to do is parse apart the full path,
delimited
by the value in the PathSeparator property. Then, you would take Nodes
property on the TreeView, and look for the first key (through the
IndexOfKey
method). Then, you take that node, and look for the next key in the
collection of TreeNode instances returned from Node.

Once you have the final node, you can call the EnsureVisible method
on
the last node, and then it will expose the node in the tree.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"James L" <Ja****@discussions.microsoft.com> wrote in message
news:1F**********************************@microsof t.com...
>I have a tree view with a root, 3 noodes(1,2,3) each having one sub
>node.
>
> I drill down to a node.
>
> I get the path by saying treeView1.selectedNode.fullpath and assign it
> to
> a
> variable.
>
> If I redraw the tree, or close it up and want to expand the same node
> again,
> can i do this via the path?
>
> Thank you kindly.


Feb 3 '06 #4
As i said earlier, i cannot see these methods you are refering to anywhere.
Is this a .net2 feature?

"Nicholas Paldino [.NET/C# MVP]" wrote:
James,

You have to call the IndexOfKey method, passing the current element in
split that you are looking at.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"James L" <Ja****@discussions.microsoft.com> wrote in message
news:96**********************************@microsof t.com...
I cannot seem to see an index of key mathod or an ensure visible method.
I have this so far.

string path = treeView1.SelectedNode.FullPath;
string delimit = @"\";
char [] delimiter = delimit.ToCharArray();
string [] split = null;

split = path.Split( delimiter );

int treeNodeIndex;
TreeNode t = new TreeNode( split[0].ToString());
treeNodeIndex= treeView1.Nodes[0].Nodes.IndexOf( t );

thanks
"Nicholas Paldino [.NET/C# MVP]" wrote:
James,

This seems a little more complicated than it should have to be.

Basically, what you have to do is parse apart the full path,
delimited
by the value in the PathSeparator property. Then, you would take Nodes
property on the TreeView, and look for the first key (through the
IndexOfKey
method). Then, you take that node, and look for the next key in the
collection of TreeNode instances returned from Node.

Once you have the final node, you can call the EnsureVisible method
on
the last node, and then it will expose the node in the tree.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"James L" <Ja****@discussions.microsoft.com> wrote in message
news:1F**********************************@microsof t.com...
>I have a tree view with a root, 3 noodes(1,2,3) each having one sub
>node.
>
> I drill down to a node.
>
> I get the path by saying treeView1.selectedNode.fullpath and assign it
> to
> a
> variable.
>
> If I redraw the tree, or close it up and want to expand the same node
> again,
> can i do this via the path?
>
> Thank you kindly.


Feb 6 '06 #5

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

Similar topics

3
by: imani_technology_spam | last post by:
We need to present hierarchical data on a web page, the same way the tree view shows files in Windows Explorer. Here's the catch: that tree view needs to be bound to a SQL Server database. How...
1
by: serge calderara | last post by:
Dear all, I have the configuration part of my application which will handle different element configuartion based on tree view object similar as MMC and snap in. Configuration data are...
4
by: erikd | last post by:
I'm using an expanding tree menu based on the design from Dieter Bungers GMD (www.gmd.de) and infovation (www.infovation.de) named displayToc.js. The problem is that the script isn't working...
2
by: weston | last post by:
So, I'm attempting to code an expanding tree menu, based off of unordered lists containing unordered lists. I'm also trying to do it in such a way that none of the javascript has to go inline with...
7
by: Andrew Robinson | last post by:
I have a treeview control that I use as a menu & navigation control within a master page. The nodes for this control are loaded from a database which contains the text and url of each like and the...
3
by: Stefan Schwarzer | last post by:
Hello, from time to time I want to inspect the source code of projects on remote computers.(*) I've googled for one or two hours but didn't find anything helpful. :-/ I'm looking for something...
0
by: =?Utf-8?B?ZGF2aWQ=?= | last post by:
Hi, I want to develop a web service client (windows form) that receives an XML file which describes a local file substructure rooted from a path. The client will use tree control generated by...
1
by: =?Utf-8?B?UHJhZGVlcCBFYXJsYQ==?= | last post by:
Hi I am having one windows application on my local machine and I want to display the folders(shared folders) of remote machine in tree view control of my win application. I haved added me as...
7
by: chaitrabharadwa | last post by:
hi all, I have a treeview and the picturebox in the form. i have a tree view which have icons for each node. i have imagelist which loads icons for nodes in the treeview. some image will be loaded...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: 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:
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.