删除图片框周围的白框?

时间:2013-10-22 11:19:44

标签: parent picturebox visual-c#-express-2010

我正在尝试将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作为其父级。

任何帮助将不胜感激。 谢谢。 文森特

1 个答案:

答案 0 :(得分:1)

尝试将PictureBox1.BorderStyle属性设置为None