14-09-20, 06:00 PM
يمكنك استخدام الدالة التالية لاحضار اي كونترول من اسمه في اي كونتينر كان
استخدامها
كود :
Function GetControl(Parent As Control, Name As String) As Control
For Each c As Control In Parent.Controls
If c.Name = Name Then Return c
Dim found = GetControl(c, Name)
If Not found Is Nothing Then Return found
Next
Return Nothing
End Functionاستخدامها
كود :
Dim txt1 As TextBox = GetControl(Me, "TextBox1")
Dim txt2 As TextBox = GetControl(Me, "TextBox2")
Dim txt3 As TextBox = GetControl(Me, "TextBox3")
Dim txt4 As TextBox = GetControl(Me, "TextBox4")
txt1.Text = "txt1"
txt2.Text = "txt2"
txt3.Text = "txt3"
txt4.Text = "txt4"
