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. get point from onclick event

get point from onclick event

Scheduled Pinned Locked Moved C#
help
5 Posts 3 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.
  • R Offline
    R Offline
    reshsilk
    wrote on last edited by
    #1

    Hello, How do you get the actual point where the mouse clicked on a form during an onclick event. Here is what I have so far, but it doesn't work... private void split_Panel2_Click(object sender, EventArgs e) { Point clickPnt = new Point(); clickPnt = (Point)sender; } Thanks for your help! RC

    J 1 Reply Last reply
    0
    • R reshsilk

      Hello, How do you get the actual point where the mouse clicked on a form during an onclick event. Here is what I have so far, but it doesn't work... private void split_Panel2_Click(object sender, EventArgs e) { Point clickPnt = new Point(); clickPnt = (Point)sender; } Thanks for your help! RC

      J Offline
      J Offline
      Josh Smith
      wrote on last edited by
      #2

      Handle the MouseDown event and cache a Point variable which you can use in the Click handler. Something like this.lastMouseDownLocation = new Point(e.X, e.Y);

      R J 2 Replies Last reply
      0
      • J Josh Smith

        Handle the MouseDown event and cache a Point variable which you can use in the Click handler. Something like this.lastMouseDownLocation = new Point(e.X, e.Y);

        R Offline
        R Offline
        reshsilk
        wrote on last edited by
        #3

        it worked! Thanks for your help!

        1 Reply Last reply
        0
        • J Josh Smith

          Handle the MouseDown event and cache a Point variable which you can use in the Click handler. Something like this.lastMouseDownLocation = new Point(e.X, e.Y);

          J Offline
          J Offline
          jjansen
          wrote on last edited by
          #4

          Josh Smith wrote:

          Handle the MouseDown event and cache a Point variable which you can use in the Click handler.

          In the Click event handler you can also use the static property Control.MousePosition. Much easier :). Alternatively, controls also have a MouseClick event which gives you the position of the mouse during the click in de event handler argument.

          J 1 Reply Last reply
          0
          • J jjansen

            Josh Smith wrote:

            Handle the MouseDown event and cache a Point variable which you can use in the Click handler.

            In the Click event handler you can also use the static property Control.MousePosition. Much easier :). Alternatively, controls also have a MouseClick event which gives you the position of the mouse during the click in de event handler argument.

            J Offline
            J Offline
            Josh Smith
            wrote on last edited by
            #5

            I was under the impression that he wanted to know where the mouse cursor was when the click process began (i.e. when the button was depressed). Checking Control.MousePosition is good if he wants to know the cursor position after the mouse button is released (MouseDown + MouseUp = Click). I suppose he didn't state either one specifically. Cheers, Josh

            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