en faite, c'était une blague, c'était la statue de la liberté la statue
cordialement
For Each ctrl As Control In Me.Controls
If TypeOf ctrl Is TextBox Then
'ici se trouve la liste des TextBox présent dans la form.
MsgBox(ctrl.Name) ' message de test visu
End If
Next
Public Class Form1
Dim nbTextBox As Integer = 1
Dim txtTemp(10) As TextBox
Private Sub ButSave_Click(sender As System.Object, e As System.EventArgs) Handles ButSave.Click
For Each ctrl As Control In Me.Controls
If TypeOf ctrl Is TextBox Then
If ctrl.Text = "" Then
MsgBox(ctrl.Name & " : Texte vide.")
Else
MsgBox(ctrl.Name & " : " & ctrl.Text)
End If
End If
Next
End Sub
Private Sub ButPlus_Click(sender As System.Object, e As System.EventArgs) Handles ButPlus.Click
nbTextBox += 1
'-------------------------------------------------------------------------------
txtTemp(nbTextBox) = New TextBox()
txtTemp(nbTextBox).Name = "TextBox" + nbTextBox.ToString()
txtTemp(nbTextBox).Size = New Point(210, 20)
txtTemp(nbTextBox).Location = New Point(13, 13 + nbTextBox * (20 + 13))
Me.Controls.Add(txtTemp(nbTextBox))
'-------------------------------------------------------------------------------
If nbTextBox >= 10 Then
' nbTextBox -= 1
ButPlus.Enabled = False
End If
If nbTextBox >= 2 Then
ButMoins.Enabled = True
End If
End Sub
Private Sub ButMoins_Click(sender As System.Object, e As System.EventArgs) Handles ButMoins.Click
'-------------------------------------------------------------------------------
Me.Controls.Remove(txtTemp(nbTextBox))
'-------------------------------------------------------------------------------
nbTextBox -= 1
If nbTextBox < 10 Then
ButPlus.Enabled = True
End If
If nbTextBox <= 1 Then
ButMoins.Enabled = False
End If
End Sub
End Class