Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Background color for control question (Win forms) 1

Status
Not open for further replies.

stfarm

Programmer
May 31, 2001
179
CA
I have a form that uses a gradient as background color. I also have some label controls on the form. I would like the label control background color to be invisible, so that the background color from the form can be seen. Is that possible?

Steve
 
Hi stfarm,

I don't think VB .NET supports transparent backgrounds for the Label control...

Can you get away without using the Label control? If you just need to display some text on the screen somewhere you could use the DrawString method of the Graphics class.

Example:

Code:
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint

    e.Graphics.DrawString("Hello", New Font("Arial", 12.0), New SolidBrush(Color.Black), 200, 200)

End Sub

Hope it helps.

T0AD

There's a thin line between genius, and insanity!
 
You can make a label transparent:
Code:
Label1.BackColor = Color.Transparent
However, on slower machines the label may paint with it's standard backcolor before the transparency is applied, making it look poor. TOAD's post is a more elegant solution.
 
TOAD's solution does work, but does make it a bit painful in trems of changing your form's layout.

Maybe I am just dumb but the Label1.BackColor = Color.Transparent will not work for me (and I am on a fast machine).

Even Microsoft's solution of using this command:
SetStyle(ControlStyles.SupportsTransparentBackColor, True)
Me.BackColor = Color.Transparent

None of these work for me when trying to get a label's backcolor to be transparent.

Does anyone know if this is possible!?

Thanks for any and all help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top