Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. ContextMenuStrip and DataGridView

ContextMenuStrip and DataGridView

Scheduled Pinned Locked Moved C#
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    FernandoMartin
    wrote on last edited by
    #1

    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

    J 1 Reply Last reply
    0
    • F FernandoMartin

      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

      J Offline
      J Offline
      Judah Gabriel Himango
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups