C# Cursor

Posted on 2005-05-12
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 85

    Accepted Solution

    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

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    If you haven’t already, I encourage you to read the first article ( in my series to gain a basic foundation of R and R Studio.  You will also find the …
    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.
    The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
    The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

    729 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now