Try the _AfterExpand event. This works in VB.Net.
Private Sub TreeView1_AfterExpand(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles
TreeView1.AfterExpand
For Each oNode As TreeNode In TreeView1.Nodes
If oNode.Index <> e.Node.Index AndAlso oNode.IsExpanded Then
oNode.Collapse()
End If
Next
End Sub
On Jul 17, 4:52 am, Benj Nunez <[email protected]> wrote:
> I got a code snippet like this that keeps one parent node expanded:
>
> protected void TreeView1_TreeNodeExpanded(object sender,
> TreeNodeEventArgs e)
> {
> string currValue = e.Node.Value.Trim();
>
> foreach (TreeNode tnode in TreeView1.Nodes)
> {
> if (tnode.Value != currValue)
> {
> tnode.Collapse();
> }
> }
>
> }
>
> I attempted to translate this on a Winforms TreeView, but it didn't
> work for me. Note that
> there is no TreeNodeExpanded() event available under Winforms. So I
> had to put my translated code under the NodeMouseClick() event. It's
> the closest that I could find that matches the code above. Any
> recommendations?