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

  • Home
  • SEARCH
  • 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 623561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:06:20+00:00 2026-05-13T19:06:20+00:00

I am implementing an application which can be drag and drop images in a

  • 0

I am implementing an application which can be drag and drop images in a panel and so I want to make sure that the image is placed within the panel and it is visible the whole image when is dropped.In that case I want to get the current cursor position when I doing drag and drop event. So how can I get the cursor location related to panel?
Here is the method of panel dragdrop event.

private void panel1_DragDrop(object sender, DragEventArgs e)
{
    Control c = e.Data.GetData(e.Data.GetFormats()[0]) as Control;

    if (c != null)
    {
        if (e.X < 429 && e.X > 0 && e.Y<430 && e.Y>0)
        {
            c.Location = this.panel1.PointToClient((new Point(e.X, e.Y)));**

            this.panel1.Controls.Add(c);
        }
    }  
}
  • 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-13T19:06:21+00:00Added an answer on May 13, 2026 at 7:06 pm

    You can get cursor coordinates using Cursor.Position, this gets you screen coordinates. you can then pass these into PointToClient(Point p)

    Point screenCoords = Cursor.Position;
    Point controlRelatedCoords = this.panel1.PointToClient(screenCoords);
    

    Though, I am fairly certain that DragEventArgs.X and DragEventArgs.Y are already screen coordinates. Your problem probably lies in

     if (e.X < 429 && e.X > 0 && e.Y<430 && e.Y>0)
    

    This looks like it would be checking against Panel coordinates, whereas e.X and e.Y are screen coordinates at that point. Instead, thansform it into panel coords before checking against bounds :

     Point screenCoords = Cursor.Position;
     Point controlRelatedCoords = this.panel1.PointToClient(screenCoords);
     if (controlRelatedCoords.X < 429 && controlRelatedCoords.X > 0 && 
         controlRelatedCoords.Y < 430 && controlRelatedCoords.Y > 0)
     {
    
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm implementing an application which want to draw lines in the panel. But the
I have a C# application in which I am implementing a drag drop functionality
I have a Silverlight (v3) application that users can drag controls (e.g. Shapes, Images)
I am implementing an application which is used to draw images and text.User can
I am implementing a desktop application in which I want to send an ALT+SPACE
I am implementing one iphone application in which i want to find direction of
I have an application in which end-users can size and position images in a
I am implementing an application that which is having a UIWebView. My problem is
I am implementing a java swing application which has a JPanel that serves as
I'm implementing a web application which will support different views according to different browsers.

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.