0
我正试图将一个groupBox2容器中的pictureBox2移动到另一个groupBox1。 问题是,在该容器中,有另一个pictureBox1,当我将pictureBox2移动到pictureBox1上时,pictureBox2会在其周围获得一个白色框。删除图片框周围的白色框?
总而言之,我想将pictureBox2融合到pictureBox1。
这里是我的代码结合了鼠标移动,向上和向下的功能:
private void pictureBox2_MouseDown(object sender, MouseEventArgs e)
{
downPoint = e.Location;
pictureBox2.Parent = this;
pictureBox2.BringToFront();
}
private void pictureBox2_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
pictureBox2.Left += e.X - downPoint.X;
pictureBox2.Top += e.Y - downPoint.Y;
}
}
private void pictureBox2_MouseUp(object sender, MouseEventArgs e)
{
Control c = GetChildAtPoint(new Point(pictureBox2.Left - 1, pictureBox2.Top));
if (c == null) c = this;
Point newLoc = c.PointToClient(pictureBox2.Parent.PointToScreen(pictureBox2.Location));
pictureBox2.Parent = c;
pictureBox2.BackColor = Color.Transparent;
pictureBox2.Location = newLoc;
this.Refresh();
pictureBox2.BringToFront();
}
我可以在任何地方移动pictureBox2并为其分配一个父,但我不能把它分配pictureBox1作为其父母,因为它只检测到groupBox2作为其父母。
任何帮助将不胜感激。 谢谢。 Vincent
我发现它是造成问题的groupBox2。删除它可以将一个pictureBox放在Form本身的另一个之前。但是,如果有任何解决上述问题,将不胜感激。 –