animekun
animekun

Reputation: 1869

Wrong appearence position of context menu

I have a datagridview and need of context menu. When i right-click on cell (RED POINT) - context menu shows.. But in wrong place. Can't understand why here is the code:

 ContextMenu m = new ContextMenu();
 m.Show(ServersTable, new Point(Cursor.Position.X, Cursor.Position.Y));

enter image description here

That stuff really annoys me!

Upvotes: 3

Views: 1205

Answers (1)

Mike Perrenoud
Mike Perrenoud

Reputation: 67898

Just translate the point to the grid:

m.Show(ServersTable, ServersTable.PointToClient(
    new Point(Cursor.Position.X, Cursor.Position.Y)));

Upvotes: 5

Related Questions