[Last Call] Learn how to a build a cloud-first strategyRegister Now


C# Cursor

Posted on 2005-05-12
Medium Priority
Last Modified: 2012-06-21
 in my program i wrote this in MouseMove Event function,

panel1.Top = Cursor.Position.Y;
panel1.Left = Cursor.Position.X;

in Y-coordinate there is a distance between the panel and the Cursor, on X-coordinate there is no distance.
how do i make no distance on Y-coordinate.

Question by:madmare
1 Comment
LVL 86

Accepted Solution

Mike Tomlinson earned 2000 total points
ID: 13987057
Why are you using the screen coordinates?  The MouseMove event gives the current cursor position relative to the control firing the event via the "e" parameter.  How about:

    panel1.Top = e.Y;
    panel1.Left = e.X;

Not sure about C# syntax but in VB.Net you can do this instead:

    panel1.Location = New Point(e.x, e.Y)

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses
Course of the Month18 days, 8 hours left to enroll

826 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question