Re: TreeView help please

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Mark Fitzpatrick (markfitz_at_fitzme.com)
Date: 12/08/04


Date: Wed, 8 Dec 2004 17:26:42 -0600

Something to keep in mind is that expanding is not the same as selecting a
node. By default, a node that is selected can also fire an expanded event.
Expanding a node therefore doesn't necessarily select it. You have to
capture the Expand event with your own handler. Let's say we had a tree
named objTree. Capturing the node that was expanded may look something like
this:

private void objTree_Expand(object sender, TreeViewClickEventArgs e)
{
    TreeNode objNode = (TreeNode)e.Node;
    string strIndex = objNode.GetNodeIndex();
}

You could probably even set the current index to equal the expanded node.

        Hope this helps,
        Mark Fitzpatrick
        Microsoft MVP - FrontPage

"clsmith66" <clsmith66@discussions.microsoft.com> wrote in message
news:68394A07-34F8-4A11-8A96-B890214792B5@microsoft.com...
> In a treeview, I am trying to store the index of every treenode as it
> expands
> in a hidden input box. If I click on the node itself, it expands and I
> can
> capture the node index no problem. If I click on the plus sign however,
> the
> selected index doesn't change so I can't capture the index of the newly
> expanded node. Does any one know how to change the selected node when a
> plus
> sign is clicked?


Quantcast