Wednesday, 21 August 2013

Assigning list (of MaskedTextBox) with list of MaskedTextBox controls in the form

Assigning list (of MaskedTextBox) with list of MaskedTextBox controls in
the form

I tried out the following code to assign the list of MaskedTextBox
controls in the from to a list msklist. But the index value is still 0
even after executing the code I have shown below. I have 30 MaskedTextBox
controls in my form.
Private msklist As New List(Of MaskedTextBox)
Private msk() As MaskedTextBox
For Each ctrl In Me.Controls
If TypeOf ctrl Is MaskedTextBox Then
msklist.Add(ctrl)
End If
Next
MsgBox(msklist.Count)
ReDim msk(msklist.Count - 1)
msk = msklist.ToArray
For i = 0 To 29 Step 1
query = "SELECT * FROM allotment_table"
cmd = New SqlCommand(query, con)
con.Open()
re = cmd.ExecuteReader
re.Read()
msk(i).Text = re("regno")
con.Close()
Next
I was hoping to assign text to the controls' Text property using for loop
with the array msk
I need some suggestions

No comments:

Post a Comment