treeview

F

feudalac!

I have a treeview wist several nodes
each node has its own context menu
for now, every menuitem in theese menues has the same code:
msgbox (treeview1.selectednode.name.tostring,okonly)

the problem is that every i click on the menuitem the message box shows
me name of the node that was selected before rightclick and thet node
is stil selected.

how do i get node name of the node where right click happened?
 
F

FUnky

private void treeView1_MouseUp(object sender,
System.Windows.Forms.MouseEventArgs e)

{

if (e.Button == MouseButtons.Right)

{

this.treeView1.SelectedNode = this.treeView1.GetNodeAt(e.X ,e.Y );

this.contextMenu1.Show(this.treeView1,new Point(e.X,e.Y));

}

}
 
F

feudalac!

FUnky izlupa:
private void treeView1_MouseUp(object sender,
System.Windows.Forms.MouseEventArgs e)

{

if (e.Button == MouseButtons.Right)

{

this.treeView1.SelectedNode = this.treeView1.GetNodeAt(e.X ,e.Y );

this.contextMenu1.Show(this.treeView1,new Point(e.X,e.Y));

}

}

Since after creating a node i do tv1.node("name").contextmenu =
contextmenuname

i just used this
this.treeView1.SelectedNode = this.treeView1.GetNodeAt(e.X ,e.Y );

it never occured to me to select it manualy


thanks
 
G

Guest

private void treeView1_MouseUp(object sender,
System.Windows.Forms.MouseEventArgs e)

{

if (e.Button == MouseButtons.Right)

{

this.treeView1.SelectedNode = this.treeView1.GetNodeAt(e.X ,e.Y );

this.contextMenu1.Show(this.treeView1,new Point(e.X,e.Y));

This line seems unnecessary, works without it.
 

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