I created an array textboxes, the frist load is good, but when I reload it again, it won't work, and I know it has to be removed before load again, but I don't know how to remove it in dynamic textboxes, they don't have textbox.name. here is my create textbox code.
Private Sub textboxShow()
setStartIndex()
setEndIndex()
clearTextboxes()'????here is the remove textboxes, but I don't know how to code this function. I have used controls.remove(), but it doesn't work either.PLS HELP!!
Dim I, J As Integer
Dim sData As Integer = 1
While sData <= iEndIndex
For I = 1 To 6
For J = 1 To 7
Call AddDataShow(sData, I, J)
sData += 1
Next
Next
End While
End Sub
Public Sub AddDataShow(ByVal sText As String, ByVal I As Integer, ByVal J As Integer)
Dim txtDataShow As New TextBox
Dim UserLft, UserTop As Integer
Dim X, Y As Integer
Dim a As Integer
a = sText - iStartIndex
UserLft = 20
UserTop = 80
txtDataShow.Height = 80
txtDataShow.Width = 80
txtDataShow.TextAlign = HorizontalAlignment.Left
txtDataShow.BorderStyle = BorderStyle.FixedSingle
txtDataShow.BringToFront()
If a > 0 And a <= iEndIndex Then
txtDataShow.Text = a
'MessageBox.Show(a)
Else
txtDataShow.Text = ""
End If
If txtDataShow.Text = "" Then
txtDataShow.BorderStyle = BorderStyle.None
Else
txtDataShow.BorderStyle = BorderStyle.FixedSingle
txtDataShow.BackColor = Color.White
End If
txtDataShow.Multiline = True
txtDataShow.ReadOnly = True
X = UserLft + (J - 1) * txtDataShow.Width
Y = UserTop + (I - 1) * txtDataShow.Height
txtDataShow.Location = New Point(X, Y)
'MessageBox.Show(X & "," & Y)
Me.GroupBox1.Controls.Add(txtDataShow)
End Sub
Private Sub textboxShow()
setStartIndex()
setEndIndex()
clearTextboxes()'????here is the remove textboxes, but I don't know how to code this function. I have used controls.remove(), but it doesn't work either.PLS HELP!!
Dim I, J As Integer
Dim sData As Integer = 1
While sData <= iEndIndex
For I = 1 To 6
For J = 1 To 7
Call AddDataShow(sData, I, J)
sData += 1
Next
Next
End While
End Sub
Public Sub AddDataShow(ByVal sText As String, ByVal I As Integer, ByVal J As Integer)
Dim txtDataShow As New TextBox
Dim UserLft, UserTop As Integer
Dim X, Y As Integer
Dim a As Integer
a = sText - iStartIndex
UserLft = 20
UserTop = 80
txtDataShow.Height = 80
txtDataShow.Width = 80
txtDataShow.TextAlign = HorizontalAlignment.Left
txtDataShow.BorderStyle = BorderStyle.FixedSingle
txtDataShow.BringToFront()
If a > 0 And a <= iEndIndex Then
txtDataShow.Text = a
'MessageBox.Show(a)
Else
txtDataShow.Text = ""
End If
If txtDataShow.Text = "" Then
txtDataShow.BorderStyle = BorderStyle.None
Else
txtDataShow.BorderStyle = BorderStyle.FixedSingle
txtDataShow.BackColor = Color.White
End If
txtDataShow.Multiline = True
txtDataShow.ReadOnly = True
X = UserLft + (J - 1) * txtDataShow.Width
Y = UserTop + (I - 1) * txtDataShow.Height
txtDataShow.Location = New Point(X, Y)
'MessageBox.Show(X & "," & Y)
Me.GroupBox1.Controls.Add(txtDataShow)
End Sub