[VB.NET]vb.net中控件的问题

前端之家收集整理的这篇文章主要介绍了[VB.NET]vb.net中控件的问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
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上画不上去。 __________________________________________________________________________

猜你在找的VB相关文章