Monday, January 31, 2011

Guide: Creating Transparent, Multiline Labels in VB.NET

To create a transparent background on a label in VB.NET, you must declare a parent to the label, then adjust the color within your form load code.

Example:
The above label was made transparent (so the background picture could show through) by the following code in the form load method:

        lblQuote.Parent = picSpiderman
        lblQuote.BackColor = Color.Transparent


As you may have noticed that labels do not have the boolean 'Multiline' property.

You can make a label multiline in two ways:

~by adjusting the parameters for the 'Maximum Size" property, and setting the Autosize property to true. The text will then autofit into the size you specify.

~by setting the Autosize property to false, and adjust the size of the label directly in the form designer.

No comments:

Post a Comment