471,319 Members | 1,920 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 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 11724
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by imani_technology_spam | last post: by
1 post views Thread by serge calderara | last post: by
7 posts views Thread by Andrew Robinson | last post: by
3 posts views Thread by Stefan Schwarzer | last post: by
reply views Thread by =?Utf-8?B?ZGF2aWQ=?= | last post: by
1 post views Thread by =?Utf-8?B?UHJhZGVlcCBFYXJsYQ==?= | last post: by
reply views Thread by rosydwin | last post: by

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.