标签背景覆盖在picturebox的被画的圈子

时间:2018-04-03 12:38:38

标签: c# drawing

我有一个名为pictureBox1的图片框,我有一个名为label1的标签,它应该位于图片框的中间。

在图片框上我需要画一个圆圈。结果是this。有没有办法让标签背景透明,所以它不会覆盖圆圈?

如果需要,我可以提供一些代码,但实际上并不多,只是一个简单的drawEllipse方法,就是这样。

1 个答案:

答案 0 :(得分:0)

要使标签的背景透明,请将标签的Parent属性更改为picturebox。 这将使标签的位置相对于图片框的位置,因此您需要重新计算标签的位置。

有关更多信息,请参阅此帖子: Transparent control over PictureBox

编辑:此代码应该适合您

        label1.BackColor = Color.Transparent;
        label1.Parent = pictureBox1;
        label1.Location = new Point(label1.Location.X - pictureBox1.Location.X, label1.Location.Y - pictureBox1.Location.Y);