The above code should work. When are you running the code? In Form_Load?
That would make all the labels on
the form transparent but if there are other labels in e.g. panels, they would not be affected because they are not in Me.Controls (the forms control collection).
Make sure that all the labels are on the form...
Another solution is to make the function recursive:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
MakeLabelsTransparent()
End Sub
Private Sub MakeLabelsTransparent()
LoopThroughCollection(Me)
End Sub
Private Sub LoopThroughCollection(ByVal parent As Control)
Dim lbls As Control
For Each lbls In parent.Controls
If TypeOf lbls Is Label Then
lbls.Parent = PictureBox1
lbls.BackColor = Color.Transparent
Else
LoopThroughCollection(lbls)
End If
Next lbls
End Sub
Please note: If you set a labels parent to PictureBox1 and the label is positioned completely or partially outside the picturebox, it will make a part or all of the label not show up at all...
Good luck