Ich habe 3 Knöpfe: 1ºbtn addiert 3 pictureboxes in flowlayoutpanel. 2ºbtn versuchen, die Kontrollen von Flow zu entfernen 3ºbtn wieder nur 2 PictureBox in flowlayoupanelWiederverwendungskontrollen bei flowlayoutpanel
die i (Loop) verwenden, um Code hinzufügen PictureBox als PictureBox1 genannt hinzuzufügen, ist picturebox2 in Flow dies:
For i As Integer = 1 To 3
If Me.Controls.ContainsKey("PictureBox" & i) Then
Me.Controls("PictureBox" & i).Visible = True
Me.Controls("PictureBox" & i).Margin = New Padding(0)
Dim px As PictureBox = CType(Me.Controls("PictureBox" & i), PictureBox)
FlowLayoutPanel1.Controls.Add(px)
End If
next
die entfernen Codes habe ich versucht, diese sind:
FlowLayoutPanel1.Controls.clear()
ich habe auch versucht:
While
(FlowLayoutPanel1.Controls.Count >)FlowLayoutPanel1.Controls.RemoveAt(0)
End While
auch:
For i As Integer = 1 to 3
If Me.Controls.ContainsKey("PictureBox" & i) Then
Me.Controls("PictureBox" & i).remove()
Me.Controls("PictureBox" & i).Visible = False
Ich habe auch versucht:
For i As Integer = 1 to 3
If Me.Controls.ContainsKey("PictureBox" & i) Then
Me.Controls("PictureBox" & i).Dispose()
Alle, die Codes funktioniert gut zu entfernen, aber dann füge ich kann nicht wieder die gleichen PictureBox in jede Flow wieder ...
Ja! das hat mein Problem gelöst !! nach 3 Tagen!! Ich füge auf die gleiche Weise die Steuerelemente zu form1 hinzu! Ich habe das ... ich bin nur supossing nur die Formen funktioniert als Container ... sehr einfach! Danke vielmals! – arc95