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 4582496
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:04:59+00:00 2026-05-21T21:04:59+00:00

I have an mdichild, and an eventhandler for draganddrop so when I drop an

  • 0

I have an mdichild, and an eventhandler for draganddrop so when I drop an image file in my form, a picturebox ( name = dpic ) is created with that image.

I have another eventhandler which is for dpic_Click, so when I click on the image, my form’s text is the name of that image.

After the first time I drop an image, another dpic is created, because you can’t have two cotrols with the same name. C# automatically changes the name and that makes my event handlers only work for the last image I dropped in. I think if I could make an event handler for my mdichild that gets the name of the control that is under the mouse pointer I could simply change back the image I am pointing at.

UPDATE

Here is my code , I made an event handler for droping in my mdichild :

void mdiChild_DragDrop(object sender, DragEventArgs e)
    {
        if (e.Data.GetDataPresent(DataFormats.FileDrop))
        {                
            dpic = new PictureBox() ;
            string[] filepath = (string[])e.Data.GetData(DataFormats.FileDrop);
            Image image = Image.FromFile(filepath[0]);
            dpic.Image = image;
            dpic.Tag = Path.GetFileName(filepath[0]);                
            this.ActiveMdiChild.Controls.Add(dpic);
            dpic.ContextMenuStrip = this.contextMenuStrip1;
            this.ActiveMdiChild.Refresh();
            dpic.BringToFront();
            this.ActiveMdiChild.ActiveControl = dpic;

            dpic.Click += new EventHandler(dpic_Click);  
// _____this helped me do it_________________________________________________
           foreach (Control c in this.ActiveMdiChild.Controls)
            {
                c.Click += new EventHandler(c_Click);
            } 
// ________________________________________________________________________
        } 
    }
  • 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-21T21:05:00+00:00Added an answer on May 21, 2026 at 9:05 pm

    What you are looking for is a sender. The sender will tell which image was clicked and will allow you to get its name.

    PictureBox picSender = (PictureBox)sender;
    label1.Text = picSender.Name;
    

    EDIT : You put that in the pic_Click event

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

Sidebar

Related Questions

I have a bunch of MDI child nodes that are all created in the
I have created MDI application in Delphi. Lets assume that I have a bunch
Have just started using Visual Studio Professional's built-in unit testing features, which as I
How do I show a MDIChild Form always on top of other MDIChild Forms
I have a project with a main MDI form. There is a child MDI
I have a MDI main form. On it I host a form, and I
I want to remove a particular tabpage from the tabcontrol. For which i have
The application that I am working on has a generic Parent Form called RSChild,
Have an app that can use tts to read text messages. It can also
Have just started using Google Chrome , and noticed in parts of our site,

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.