OnMouseUp behaving strangely

  • Thread starter Thread starter Aaron Queenan
  • Start date Start date
A

Aaron Queenan

I have an event handler in a subclass of TreeView:

protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Right)
this.contextMenu.Show(this, new System.Drawing.Point(e.X, e.Y));
base.OnMouseUp(e);
}

When I right click, the menu pops up. If I left click somewhere outside the
menu, the menu disappears, but thereafter every LEFT click causes the event
to be fired again with e.Button == System.Windows.Forms.MouseButtons.RIGHT.

It works correctly in the list view.

Any suggestions as to what could be causing this and how to fix it?

Thanks,
Aaron Queenan.
 
If the first left click is over an item, the problem occurs. If the first
left click is over the control background, the problem doesn't occur.
 
Sorry, I should have said (if the first left click is over an item's
CHECKBOX). The treeview and listview I am using both have checkboxes
visible.

Thanks,
Aaron.
 
Back
Top