Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3667490
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:00:26+00:00 2026-05-19T02:00:26+00:00

I am using Windows Forms in C#, and I would like to make a

  • 0

I am using Windows Forms in C#, and I would like to make a function that does the following:
When the user clicks on the form, “something” will be drawn in the location that the user clicked.

I have two questions:
1) Is there a best practice/recommended way of doing this? Right now I am using the Windows EventHandler that fires when the mouse is clicked, getting the cursor’s location, and then drawing the object in that location.

2) When I draw the object in the location of “Cursor.Position,” it is actually drawn significantly further away than where the actual cursor is located. (It draws it down and to the left.) Is there some type of transformation that must be done on Cursor.Position to get the screen coordinates?

Below I have demonstrated some simplified sample code. You see that I register the form with the “Click” EventHandler. Then, when the EventHandler fires, I call a function that simply draws a label on the form.

Thanks in advance for your help.

MyForm myForm = new myForm();
myForm.Click += new System.EventHandler(this.MyForm_Click);

_

private void MyForm_Click(object sender, EventArgs e)
{
    Point p = Cursor.Position;    // Does this get the correct position?
    DrawObject(p);
}

private void DrawObject(Point p)
{
    Label l = new Label()
    l.Size = new System.Drawing.Size(300, 300);
    l.Text = "New Label";
    l.Location = p;
    this.Controls.Add(l);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T02:00:27+00:00Added an answer on May 19, 2026 at 2:00 am

    Instead of using Cursor.Position, you should subscribe to the MouseClick event. This will provide you location information in the handler itself.

    Cursor.Position will give you coordinates in screen coordinates. If you want to use it, you’ll need to use PointToClient to map it to your form’s coordinate space.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If i were developing a screensaver using a windows.form in C# how would i
I'm using Windows Forms and VS2008. I want to store an enum value in
I am using standard windows forms controls under C#. I have two controls which
Most of my programming experience has either been using forms (Windows Forms, or ASP.NET)
My users are having an intermittent error when using a Windows Forms application built
How do I enable double-buffering of a control using C# (Windows forms)? I have
I have a little demonstration below of a peculiar problem. using System; using System.Windows.Forms;
I am using C# and Windows Forms. I have a normal progress bar working
We have a fairly complicated GUI in windows forms using C# and .Net 2.0.
Sometimes I create some quick personal projects using C# with Windows Forms or WPF

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.