I am having very little success when I set the property of the BackColor of a label to Transparent.
Does anyone know how to do this so I can put text over a color gradient
I am having very little success when I set the property of the BackColor of a label to Transparent.
Does anyone know how to do this so I can put text over a color gradient
Transparent labels
smargroth
Sadly ( for me), I've tried this and various other (messier) solutions I've found on the web, and not one of them works. I am adding a label to my form dynamically, I dunno if that makes any difference:
class TransparentLabel : Label
{
public TransparentLabel(){
SetStyle(
ControlStyles.SupportsTransparentBackColor, true);}
}
TransparentLabel l = new TransparentLabel(); using (Font f = new Font("Verdana", 340)){
Controls.Add(l);
l.Name =
"Label";l.ForeColor =
Color.Red;l.BackColor =
Color.Transparent;l.Top = 0;
l.Left = 0;
l.Width =
this.Width;l.Height =
this.Height;l.TextAlign =
ContentAlignment.MiddleCenter;l.Font = f;
l.Text = number.ToString();
l.BringToFront();
I'd appreciate any help. Perhaps some insight into why this state of affairs is not idiotic would also be cool :-)
AlbinCN
In order to assign the Color.Transparent to any control BackColor you need to ensure the control is setup with the ability to handle it. Derive a class from Label and in the constructor add...
SetStyle(
ControlStyles.SupportsTransparentBackColor, true);...and then it should work.
Phil Wright
http://www.componentfactory.com
Free UI controls for .NET2