Hi there,

got a little problem with backcolor aof labels:
I have a picture box and a label on top of it. But when setting the
backcolor of the label transparent, I still see the grey rectangle of the
label and not the picturebox behind the text. How can I realize this?

Thanx

Rudy

Re: How can I set a label transparent? by Morten

Morten
Fri May 14 03:46:33 CDT 2004

Hi Rudy,

A way around this, not using labels, is to drawstring the text directly onto the picturebox. You can still put a label ontop of the picturebox and use it in design and at runtime, but set it to visible = false and let the drawstring paint it, using whatever property label1 has.

private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawString(label1.Text, label1.Font, new SolidBrush(label1.ForeColor), label1.Left - pictureBox1.Left, label1.Top - pictureBox1.Top);
}


Happy coding!
Morten Wennevik [C# MVP]

Re: How can I set a label transparent? by Rudy

Rudy
Fri May 14 04:34:18 CDT 2004

Thank you very much!

"Morten Wennevik" <MortenWennevik@hotmail.com> schrieb im Newsbeitrag
news:opr7zenvk4klbvpo@morten_x.edunord...
> Hi Rudy,
>
> A way around this, not using labels, is to drawstring the text directly
onto the picturebox. You can still put a label ontop of the picturebox and
use it in design and at runtime, but set it to visible = false and let the
drawstring paint it, using whatever property label1 has.
>
> private void pictureBox1_Paint(object sender, PaintEventArgs e)
> {
> e.Graphics.DrawString(label1.Text, label1.Font, new
SolidBrush(label1.ForeColor), label1.Left - pictureBox1.Left, label1.Top -
pictureBox1.Top);
> }
>
>
> Happy coding!
> Morten Wennevik [C# MVP]