By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,660 Members | 1,562 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,660 IT Pros & Developers. It's quick & easy.

How to move to next node in TreeView?

P: n/a
I want to write code to move to the next node in a TreeView. The code will
behave similar to when the user presses down arrow. Thanks.
Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Will that auto-scroll to the out of view items?

If it doesn't, you can hit the treeView.Nodes with an index and set
that one to ".EnsureVisible=true" (or is that a method call now?)

TreeNode.NextVisibleNode is the property you're looking for.

private void NextVisibleNode(TreeView treeView)
{
treeView.SelectedNode = treeView.SelectedNode.NextVisibleNode;
}

Of course, check for null values etc. in actual code.

Nov 13 '05 #2

P: n/a
NextVisibleNode does not scroll to out of view nodes. Here is part of my
code:
// Make sure the children nodes at the currently selected node are visible
tvwFolders.SelectedNode.Expand();

// Select the next node in the TreeView
tvwFolders.SelectedNode = tvwFolders.SelectedNode.NextVisibleNode;

Thanks for the additional tips.
"Chris Hornberger" <ch***@chornbe.com> wrote in message
news:53**************************@posting.google.c om...
Will that auto-scroll to the out of view items?

If it doesn't, you can hit the treeView.Nodes with an index and set
that one to ".EnsureVisible=true" (or is that a method call now?)

TreeNode.NextVisibleNode is the property you're looking for.

private void NextVisibleNode(TreeView treeView)
{
treeView.SelectedNode = treeView.SelectedNode.NextVisibleNode;
}

Of course, check for null values etc. in actual code.

Nov 13 '05 #3

P: n/a
Thanks a lot. I replaced my 20 or so lines of code, which even had a bug
because it was not recursively looking at parent nodes.
"bjs10" <su******@bellsouth.net> wrote in message
news:58**************************@posting.google.c om...
"someone" <a@a.com> wrote in message

news:<e1*************@tk2msftngp13.phx.gbl>...
I want to write code to move to the next node in a TreeView. The code will behave similar to when the user presses down arrow. Thanks.


TreeNode.NextVisibleNode is the property you're looking for.

private void NextVisibleNode(TreeView treeView)
{
treeView.SelectedNode = treeView.SelectedNode.NextVisibleNode;
}

Of course, check for null values etc. in actual code.

Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.