通过单击图像在位置480,380上的另一个图片框图像上设置一个图片框图像

问题描述:

我希望通过点击图像将位置480,380上的另一个图片框图像设置为一个图片框图像。我不知道如何设置以及在哪里编写代码。像颈部一样会通过点击添加到客户图像颈部。紧急和我将感谢你。

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.

假设你有两个PictureBox,pictureBox1,pictureBox2,它们都是相同的大小,你想要点击pictureBox1来移动pictureBox1因此它完全覆盖了PictureBox2:



1.在Visual Studio设计器中,双击pictureBox1:您将自动切换到表单的代码视图窗口,您将看到为您生成Click事件的空白EventHandler。



2将以下代码添加到EventHandler:

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:
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();
}

对我来说,您的问题表明您需要熟悉在Visual Studio的工具选项板上使用内置控件的基本功能。每个Control,如果双击,将生成某种EventHandler(它们将根据Control而有所不同,但最常见的是Click EventHandler。

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.