前端之家收集整理的这篇文章主要介绍了
[VB.NET]vb.net中控件的问题,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
vb.net中控件的问题 Private Const st As String = "text " Private oSt As Text
Box 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,Text
Box) oSt.Text = "1 " Next End Sub 有没有办法实现这样的
功能。请高手指教 __________________________________________________________________________ For Each ctrl As Control In Me.Controls If ctrl.GetType.Name = "Text
Box " Then CType(ctrl,Text
Box).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 Text
Box For i As Integer = 0 To 1 oSt(i) = New Text
Box 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 __________________________________________________________________________ 楼上的说得对,用控件数组 __________________________________________________________________________ 哦,用text
BoxArray么,初始化的时候,固定位置么。用控件数组在form上画不上去。 __________________________________________________________________________
原文链接:https://www.f2er.com/vb/263831.html