Hola Comunidad aqui intentando con este dolor de cabeza, bueno tengo este
arrays (codigo abajo) que me permite crear n label como Textbox, lo crea con
total normalidad, pero el problema que tengo es una vez creado el arrays como
lo verifico q texto es el que esta realizando el evento TextChanged o en que
texto esta el foco (GotFocus)
Gracias de ntemano su respuesta.
Private labelCampos() As Label
Private txtCampos() As TextBox
Public Sub CrearCampos(ByVal cols As Integer)
Dim k, a As Integer
Try
For Each con As Control In Me.txtCampos
Me.Controls.Remove(con)
Next
For Each con As Control In Me.labelCampos
Me.Controls.Remove(con)
Next
If cols = 0 Then Exit Sub
Catch ex As Exception
End Try
ReDim labelCampos(cols - 1)
ReDim txtCampos(cols - 1)
k = 0
For i As Integer = 0 To cols - 1
If i >= 0 Then
labelCampos(i) = New Label
txtCampos(i) = New TextBox
k += 1
labelCampos(i).TabIndex = k
k += 1
txtCampos(i).TabIndex = k
labelCampos(i).Name = "LabelCampo_" & i.ToString()
txtCampos(i).Name = "txtCampo_" & i.ToString()
txtCampos(i).Size = New System.Drawing.Size(150, 20)
If i = 0 Then
Me.labelCampos(i).Location = New System.Drawing.Point(7,
27)
Me.txtCampos(i).Location = New System.Drawing.Point(7, 41)
Else
txtCampos(i).Location = txtCampos(i - 1).Location
labelCampos(i).Location = labelCampos(i - 1).Location
labelCampos(i).Left += 150
txtCampos(i).Left += 150
End If
Me.Controls.Add(txtCampos(i))
Me.Controls.Add(labelCampos(i))
End If
a = i
Next
Me.txtCampos(a).Focus()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
CrearCampos(2)
End Sub