Click here to Skip to main content
15,902,874 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want set one picturebox image on another picturebox image on location 480,380 by clicking on the image.i dont know how to set and where to write the code.its like neckels will add on customer image neck by clicking.its urgent and i will be thankful to u.
Posted
Comments
BillWoodruff 19-Sep-13 4:45am    
Is this WinForms or WPF ? What have you tried so far ?
Member 10279150 19-Sep-13 7:41am    
windforms

1 solution

Assuming you have two PictureBoxes, pictureBox1, pictureBox2, that are both the same size, and you want clicking on pictureBox1 to move pictureBox1 so it completely covers pictureBox2:

1. in the Visual Studio designer, double-click on pictureBox1: you will be automatically switched to the code-view window for your Form, where you'll see a "blank" EventHandler for the Click Event has been generated for you.

2 add the code below to the EventHandler:
C#
private void pictureBox1_Click(object sender, EventArgs e)
{
    pictureBox1.Location = pictureBox2.Location;

    // or ...
    // ... pictureBox1.Location = new Point(480,380)

    // in case pictureBox1 is behind pictureBox2
    pictureBox1.BringToFront();
}
To me your question shows that you need to get familiar with the basic functions of using the built-in Controls on the Tool palette in Visual Studio. Each Control, if double-clicked, will generate some kind of EventHandler (they will vary based on the Control, but the most common is a Click EventHandler.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900