1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
Public Class Form1
Dim positionLigne As Integer = 40 'position Height du composant
Dim choixCb1 As String = Nothing 'affecté par Cb1.SelectedValueChanged
'Chargement d'une liste de choix lors du FormLoad()
Private Sub loadComposant()
Dim Cb1 As New ComboBox
Cb1.Items.Add("Nom")
Cb1.Items.Add("Prénom")
Cb1.Location = New System.Drawing.Point(0, 0)
Controls.Add(Cb1)
AddHandler Cb1.SelectedValueChanged, AddressOf Cb1SelectedValueChanged
End Sub
'Chargement d'une textBox pour la nouvelle ligne, survenu par la sélection d'un choix dans Cb1
Private Sub loadLigne(ByVal par_choixCb1 As String)
Dim txt1 As New TextBox
txt1.Location = New System.Drawing.Point(0, positionLigne)
txt1.Text = "Tapez un(e) " & par_choixCb1
Controls.Add(txt1)
positionLigne += 30
End Sub
'
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
loadComposant()
End Sub
'
Private Sub Cb1SelectedValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
'pour info :
' => sender.ToString renvoie => System.Windows.Forms.ComboBox, Items.Count: 2
' => e.ToString renvoie => System.EventArgs
'PROBLEME :
' ??? choixCb1 = Cb1.TextChanged => Cb1. inexistant lors du codage
loadLigne(choixCb1)
End Sub
End Class |
Partager