Hello Folks Vist vore det behändigt med en C0ontrols collection på alla container kontroller. Tyvärr finns det inte i vb 6.<br>For Each ?
Detta fixar jag inte.
Jag har en PictureBox som i sin tur innehåller en "flock" Label:s
Jag vill manipulera bara dom Label :ar som finns i PictureBoxen
For Each Label In Picture1 . Funkar ju inte
Next
Undrar
SvenSv: For Each ?
<br>
Om man inte använder en UserControl vilket internt stödjer ContainedControls.<br>
<br>
Dukan ju skapa dina egna collectioner:
<code>
Option Explicit
Private mPicture1_Controls As Collection
Public Function ContainedControls(Controls As Object, Container As Control) As Collection
Dim Ctrl As Control
Dim ExCtrl As VBControlExtender
Set ContainedControls = New Collection
For Each Ctrl In Controls
If TypeOf Ctrl Is VBControlExtender Then
Set ExCtrl = Ctrl
If ExCtrl.Container Is Container Then
ContainedControls.Add ExCtrl
End If
End If
Next
End Function
Private Sub Form_Load()
Set mPicture1_Controls = ContainedControls(Me.Controls, Picture1)
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set mPicture1_Controls = Nothing
End Sub
</code>