ContextMenuStrip and DataGridView
-
Hello, I have to show a ContextMenuStrip in the Header of the DataGridView. In the event ColumnHeaderMouseClick do datagridview i catch the coordenates e.X and e.Y of the mouse, but the ContextMenu doesn't appear where the mouse is, i always appears in the first columns. look the image thank you a lot
-
Hello, I have to show a ContextMenuStrip in the Header of the DataGridView. In the event ColumnHeaderMouseClick do datagridview i catch the coordenates e.X and e.Y of the mouse, but the ContextMenu doesn't appear where the mouse is, i always appears in the first columns. look the image thank you a lot
The e.X and e.Y coordinates are probably local. Convert them to screen coordinates before showing the context menu:
Point localPoint = new Point(e.X, e.Y);
Point screenPoint = dataGridView.PointToScreen(localPoint);
myContextMenu.Show(screenPoint...);Tech, life, family, faith: Give me a visit. I'm currently blogging about: Roman Catholic Relevance? The apostle Paul, modernly speaking: Epistles of Paul Judah Himango