Help me with this odd mouse click problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a DataGrid which I added a MouseUp event:

datagrid.MouseUp += new MouseEventHandler(onMouseUp);

which simply does:

if (e.Button == MouseButtons.Right) {
if(hti.Type == DataGrid.HitTestType.ColumnHeader) {
main_dg.ContextMenu = columnHeaderMenu;
} else if (hti.Type == DataGrid.HitTestType.Cell) {
main_dg.ContextMenu = leftClickCellMenu;
}
}

Now, this once worked fine, but lately something really odd has been
happening...

It seems to use the mouse coordinates of the LAST click... not the current
click- what in the world could cause that?

So for example, when I first load the dialog and right click the column
header, nothing happens. Then if I right-click a Cell, the Column Header menu
pops up. If I then right-click the column header, the Cell context menu pops
up! Whatever I last clicked seems to be the current target...

Why??
 
Some more information:

I mad eit output the coords:

Console.WriteLine("Point is {0},{1}", e.X, e.Y);

and it turns out the coordinates given by MouseEventArgs is giving my
function the coords of the last mouse click

Under what circumstances would the mouse event give coordinates of the last
mouse event instead of the current one, and saving the current one for the
next event?? I am not doing anything crazy on this dialog... this is really
the only event I'm using on this Form and no other Forms even touch Mouse
Events

This is very strange
 

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

Back
Top