By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,041 Members | 1,056 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,041 IT Pros & Developers. It's quick & easy.

How to set a label's backcolor to transparent?

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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

"Dean Slindee" <sl*****@charter.net> wrote in message
news:ys************@fe06.lga...
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

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.