Hey people!
I'm creating a small project which consists of 36 textboxes and one button.
When I click a textbox, it should open a open file dialog and, when OK, set the text of the textbox I've clicked to the file name.
I've did this:
Public Class Form1
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.Click, TextBox2.Click, TextBox3.Click, TextBox4.Click, TextBox5.Click, TextBox6.Click, TextBox7.Click, TextBox8.Click, TextBox9.Click, TextBox10.Click, TextBox11.Click, TextBox12.Click, TextBox13.Click, TextBox14.Click, TextBox15.Click, TextBox16.Click, TextBox17.Click, TextBox18.Click, TextBox19.Click, TextBox20.Click, TextBox21.Click, TextBox22.Click, TextBox23.Click, TextBox24.Click, TextBox25.Click, TextBox26.Click, TextBox27.Click, TextBox28.Click, TextBox29.Click, TextBox30.Click, TextBox31.Click, TextBox32.Click, TextBox33.Click, TextBox34.Click, TextBox35.Click, TextBox36.Click
Dim abrir As New OpenFileDialog
With abrir
.Filter = "M2TS|*.m2ts"
End With
If abrir.ShowDialog = DialogResult.OK Then
Dim CheckBoxNumber As Integer
Dim NewCheckBoxTextValidator As Integer
For i As Integer = 1 To 36
CheckBoxNumber = i
NewCheckBoxTextValidator = Me.Controls.IndexOfKey("TextBox" & CheckBoxNumber.ToString)
DirectCast(Me.Controls.Item(NewCheckBoxTextValidator), TextBox).Text = abrir.FileName
Next
End If
End Sub
End Class
But, it don't work. It don't replace only the clicked textbox, but all textboxes. How can I fix it?
Thanks!