Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
C# Control - Transparent Label
Message
De
09/10/2007 18:35:17
 
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Divers
Thread ID:
01259615
Message ID:
01259898
Vues:
14
>I have no code.

Well, of course there's code Kevin ... the code that's generated in the Designer.cs. But, nevermind ... this seems to work fine if the parent is a Form, or a Panel, or some other Control, but it doesn't seem to work if the parent is a PictureBox. There's a note on that link you showed that says this:

Windows Forms controls do not support true transparency. The background of a transparent Windows Forms control is painted by its parent.

The problem is this ... the label's parent is the Panel, not the PictureBox. I'm not sure you can make the PictureBox the parent of the label.

~~Bonnie




>
>All I have done so far is place a Panel control on a form. I then added a PictureBox in the panel and set it's Image to a blue verticle gradient.
>
>I then placed a label in the Panel, over the gradient image, near the top. The label's background appears as a white rectangle.
>
>My website is down, othewise I would post a screenshot.
>
>As far as that code I found - I'm not sure where this code goes.
>
>
>
>
>
>
>>Kevin,
>>
>>That article seems pretty straightforward to me, I'm not sure what you're not understanding.
>>
>>How about we try this ... post the relevant code here and maybe we'll be able to spot the problem.
>>
>>~~Bonnie
>>
>>
>>
>>>I'm still not getting it. Why can't I make a label transparent????
>>>
>>>I found this article, but I need help understanding what it's telling me to do.
>>>http://msdn2.microsoft.com/en-us/library/wk5b13s4.aspx
>>>
>>>
>>>
>>>
>>>>You'd need to set the control style to support transparency
>>>>
>>>>
>>>> private bool _HacerTransparente;
>>>>        public bool HacerTransparente
>>>>        {
>>>>            get { return _HacerTransparente; }
>>>>            set
>>>>            {
>>>>                _HacerTransparente = value;
>>>>
>>>>                this.SetStyle(ControlStyles.SupportsTransparentBackColor, _HacerTransparente);
>>>>                if (_HacerTransparente)
>>>>                {
>>>>                    BackColor = Color.Transparent ;
>>>>                }
>>>>                else
>>>>                {
>>>>                    BackColor = BackGroundColor;
>>>>                }
>>>>            }
>>>>        }
>>>>
>>>>
>>>>HTH,
>>>>
>>>>Enmanuel
>>>>
>>>>>I have tried both, and it has no effect. The label is not transparent.
>>>>>
>>>>>I have a panel control with a picturebox in it of a gradient. The label is then on top of the gradient. The label appears as black text inside a white rectangle.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>>How do I set the background of a label to transparent?
>>>>>>
>>>>>>
>>>>>>this.MyLabel.BackColor = System.Drawing.Color.Transparent;
>>>>>>
>>>>>>
>>>>>>Or, from the PropertySheet's color picker, choose the Web tab to find the Transparent color.
>>>>>>
>>>>>>~~Bonnie
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform