How to set a label's backcolor to transparent?

D

Dean Slindee

The code below runs in the form_paint event but changes nothing, anyone got
a better idea or why this code is not effective?

Imports System.Drawing.Drawing2D

Dim ctl As Control

Dim str As String

For Each ctl In Me.Controls

str = ctl.GetType.ToString

If str = "System.Windows.Forms.Label" Then

ctl.BackColor = System.Drawing.Color.Transparent

End If

Next

Thanks,

Dean Slindee
 
R

rawCoder

The Transparent will set the control to be transparent with respect to its
parent
So Incase of the label, it will become transparent for the Form and if the
form has a background image will show through the label.
But the lable cant be transparent for other controls.
In case you want some heirarchial transparency, then you can manoeuvr the
parent/child relationships of the controls to do this.

HTH
rawCoder
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top