tree view

  • Thread starter Thread starter Stephen Haunts
  • Start date Start date
S

Stephen Haunts

Ok, I've got a tree view in my app, and when I click a new leaf with the
left mouse button I handle the AfterSelect event and change the context menu
for the tree view. But if I select the tree leaf with the right mouse
button it doesn't fire that event. How can I get it to fire the AfterSelect
event from the right mouse button.

Regards

Steve
 
Ok, I've got a tree view in my app, and when I click a new leaf with the
left mouse button I handle the AfterSelect event and change the context menu
for the tree view. But if I select the tree leaf with the right mouse
button it doesn't fire that event. How can I get it to fire the AfterSelect
event from the right mouse button.

I use this code snippet on the "MouseDown" event:

protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);

if (e.Button == MouseButtons.Right)
{
Point pt = new Point(e.X, e.Y);
this.PointToClient(pt);

TreeNode oCurrNode = this.GetNodeAt(pt);
if (oCurrNode == null)
return;

if (oCurrNode.Bounds.Contains(pt))
{
this.SelectedNode = oCurrNode;
}
}
}

HTH
Marc

================================================================
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
 
Back
Top