Removing a SelectedNode from Treeview

G

Guest

Hi, I have a treeview, called Treeview1 with one father node and some
children nodes. Number of children nodes can change since every child node is
a file name that the user add through an Open DialogBox.

I'd like the user to be able to remove one or more children nodes by
selecting them. But if I use the following syntax:

Dim Mynode As TreeNode
Mynode = TreeView1.SelectedNode.Nodes(0)
Mynode.Remove()

the first child node is always removed, even if it's not selected while the
selected node stays where it was...where's my mistake?

thanks!!
 
H

Herfried K. Wagner [MVP]

Progalex said:
Hi, I have a treeview, called Treeview1 with one father node and some
children nodes. Number of children nodes can change since every child node
is
a file name that the user add through an Open DialogBox.

I'd like the user to be able to remove one or more children nodes by
selecting them. But if I use the following syntax:

Dim Mynode As TreeNode
Mynode = TreeView1.SelectedNode.Nodes(0)
Mynode.Remove()

\\\
Me.TreeView1.SelectedNode.Remove()
///
 
G

Guest

The syntax:

Me.TreeView1.SelectedNode.Remove()

seems to work.

I used it without specifying "Me" and it seemed to remove the entire
structure of the treeview... very strange!

But thanks a lot!
 
H

Herfried K. Wagner [MVP]

Progalex said:
Me.TreeView1.SelectedNode.Remove()

seems to work.

Glad to hear that.
I used it without specifying "Me" and it seemed to remove the entire
structure of the treeview... very strange!

Mhm... This should not be the case...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top