[英]Add rows to DataGridView based on TextBox text
我需要基於文本框中的數字添加一定數量的行。 如果我在文本框中輸入數字,則會增加行數。
例如, Textbox.Text = "7"
產生7個新行
我該怎么做?
它可能看起來像:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim numRows As Integer
If Integer.TryParse(TextBox1.Text, numRows) Then
If (numRows >= 1) Then
For i As Integer = 1 To numRows
DataGridView1.Rows.Add()
Next
Else
MessageBox.Show("Value: " & TextBox1.Text, "Number of Rows must be Greater Than or Equal to 1")
End If
Else
MessageBox.Show("Value: " & TextBox1.Text, "Invalid Integer")
End If
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.