我是vb.net的新手,我已成功动态生成文本框,如下图
但我的问题是,我希望我的输出像这样
我一直使用下面的代码来生成那些文本框。任何人都可以修复我的代码。感谢
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
Dim table1 As Table
table1 = GetRow(txtRow.Text)
table1 = GetColumn(txtColumn.Text)
End Sub
Private Function GetRow(ByVal strRow As String)
Dim txt1 As TextBox
Dim i As Integer = 0
While i < "" & txtRow.Text & ""
txt1 = New TextBox()
txt1.ID = "myTextBox" & i
Panel1.Controls.Add(txt1)
Dim lit As New Literal()
Panel1.Controls.Add(lit)
System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)
End While
End Function
Private Function GetColumn(ByVal strColomn As String)
Dim txt1 As TextBox
Dim i As Integer = 0
While i < "" & txtColumn.Text & ""
txt1 = New TextBox()
txt1.ID = "myTextBox" & i
Panel1.Controls.Add(txt1)
Dim lit As New Literal()
lit.Text = "<br>"
Panel1.Controls.Add(lit)
System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)
End While
End Function
End Class
答案 0 :(得分:0)
您可以使用像
这样的子句添加控件private sub generate_table
for (i=0) to txtRow.Text do
for (j=0) to txtColumn.Text do
txt1 = New TextBox()
txt1.ID = "myTextBox" & (i + j).tostring
txt1.Location = New Point(i * tzt1.Size.Height, j * txt1.Size.Width)
Panel1.Controls.Add(txt1)
end for
end for
end sub