using control arrays

落花浮王杯 提交于 2020-01-30 13:13:21

问题


i am having trouble with .net again. i have a series of 10 text boxes. I want to be able to populate them from an array and read there values into another array. In vb6 I would create a text box array with 10 text boxes / indices. I could then populate them by txtbox(i).text = arrVal(i) and to reference them arrVal(i) = txtbox(i). I am stumped I can create 10 text boxes on a form if I have to, but I want them somehow tied to each other as they were in vb6. Any help in how I could do this would be most appreciated


回答1:


Control arrays as available in VB6 are not supported in VB.NET. Not an issue, just create the array yourself:

Public Class Form1
    Sub New()
        InitializeComponent()
        Boxes = New TextBox() {TextBox1, TextBox2, TextBox3}
    End Sub

    Private Boxes() As TextBox

End Class


来源:https://stackoverflow.com/questions/10695728/using-control-arrays

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!