How to change a control into an array?
-
Here is a control on a winform. I want to create an array of this control. In vb 6.0 , we just copy and paste the control, the compiler will create array of control automautically. However, we could not do so in vs.net. Maybe friends will teach me. Thanks!
-
Here is a control on a winform. I want to create an array of this control. In vb 6.0 , we just copy and paste the control, the compiler will create array of control automautically. However, we could not do so in vs.net. Maybe friends will teach me. Thanks!
' For array of text boxes Dim txtBoxArray as TextBox() Dim x as Integer For Each ctl As Control In Me.Controls If TypeOf ctl Is TextBox Then ReDim Preserve txtBoxArray(x) txtBoxArray(x) = ctl x += 1 EndIf Next
You can access them like txtBoxArray(0), txtBoxArray(1), ect... -
Here is a control on a winform. I want to create an array of this control. In vb 6.0 , we just copy and paste the control, the compiler will create array of control automautically. However, we could not do so in vs.net. Maybe friends will teach me. Thanks!
Do array of controls in your code Contols like any object in .net so you can create control of TextBoxs for example Dim textBoxs(5) As TextBox and access each control via index MCAD