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. c#

c#

Scheduled Pinned Locked Moved C#
questioncsharp
4 Posts 4 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.
  • Z Offline
    Z Offline
    zofi51
    wrote on last edited by
    #1

    what is the code in c# in mouse move event to display the current mouse position in form?

    A B OriginalGriffO 3 Replies Last reply
    0
    • Z zofi51

      what is the code in c# in mouse move event to display the current mouse position in form?

      A Offline
      A Offline
      Abhinav S
      wrote on last edited by
      #2

      You can try MouseHover[^] or MouseMove[^].

      Apps - Color Analyzer | Arctic | XKCD | Sound Meter | Speed Dial

      1 Reply Last reply
      0
      • Z zofi51

        what is the code in c# in mouse move event to display the current mouse position in form?

        B Offline
        B Offline
        bfis108137
        wrote on last edited by
        #3

        To get the position you just use the MouseEventArgs X and Y values. Using the standard visual studio format your code would look like this for a label called label1 that moved with the mouse.

        private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
        label1.Location = new Point(e.X, e.Y);
        }

        From here

        1 Reply Last reply
        0
        • Z zofi51

          what is the code in c# in mouse move event to display the current mouse position in form?

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #4

          Try:

          Point mouseAt = PointToClient(Cursor.Position);
          Console.WriteLine(mouseAt);

          The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          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