right click in windows form

  • Thread starter Thread starter Tim Wallace
  • Start date Start date
T

Tim Wallace

I have a simple app that I'm building using C# (using Visual C# Express
Edition). In it, I open an mdi child window that contains a treeview. I
want to display a context menu when the user right clicks the treeview.
When the window opens, I have to click on the treeview twice to get the menu
to show. I've tried setting the focus to the treeview in the Load even, to
no avail.

Any ideas?

Tim
 
Hi
you have to use the treeview mouse down event like that:
private void treeView1_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
if(e.Button==MouseButtons.Right)
{
Point p=new Point(e.X,e.Y);
contexmenu1.Show(treeView1,p);
}
}
 
Back
Top