![VB.NET源码-156个实用实例哦……](http://www.zhzx123.com/VB.NET_03.gif)
vb.net中控件的问题
Private Const st As String = "text "
Private oSt As TextBox
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Short
For i = 0 To 1
oSt = CType(st & i + 1, TextBox)
oSt.Text = "1 "
Next
End Sub
有没有办法实现这样的功能。请高手指教
__________________________________________________________________________
For Each ctrl As Control In Me.Controls
If ctrl.GetType.Name = "TextBox " Then
CType(ctrl, TextBox).Text = "Teee "
End If
Next
__________________________________________________________________________
我觉得最好是用控件数组来做:
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim oSt(80) As TextBox
For i As Integer = 0 To 1
oSt(i) = New TextBox
oSt(i).Text = "1 "
oSt(i).Left = 12 + (oSt(i).Width + 6) * i
oSt(i).Top = 12
Me.Controls.Add(oSt(i))
Next
End Sub
End Class
__________________________________________________________________________
楼上的说得对,用控件数组
__________________________________________________________________________
哦,用textboxArray么,初始化的时候,固定位置么。用控件数组在form上画不上去。
__________________________________________________________________________