How to increase the number of row in a vb.net form?
how to increase the number of row of a table in a form in vb.net when the number of row are controlled by the user using a textbox? anyone have any idea...
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Syed ShanuRank #87 · 23.7K reputationPosted Jul 15, 2015, 12:35 AM EDT
{
{
dt.Rows.Clear();
for (int i = 1; i <= rowsCount; i++)
{
DataRow row = dt.NewRow();
row["NO"] = i.ToString();
for (int jval = 1; jval <= totalColumntoDisplay; jval++)
{
row["Name"] ="";
}
dt.Rows.Add(row);
}
Govinda Rajulu YemineniRank #1,517 · 1K reputationPosted Jul 19, 2015, 4:28 AM EDT
Manoj BhoirRank #599 · 4K reputationPosted Jul 19, 2015, 5:09 AM EDT
Public Class Form1
Private mDataable As DataTable
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
For mRow As Int16 = 1 To Val(Me.TextBox1.Text)
Dim mNewRow As DataRow = mDataable.NewRow
mNewRow("SerialNo") = ""
mNewRow("FirstName") = ""
mNewRow("MiddleName") = ""
mNewRow("LastName") = ""
mDataable.Rows.Add(mNewRow)
Next
Me.DataGridView1.DataSource = mDataable
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
mDataable = New DataTable
mDataable.Columns.Add("SerialNo")
mDataable.Columns.Add("FirstName")
mDataable.Columns.Add("MiddleName")
mDataable.Columns.Add("LastName")
End Sub
End Class
Also find attahced Sample.Syed ShanuRank #87 · 23.7K reputationPosted Jul 15, 2015, 12:08 AM EDT
King Umar106 reputationPosted Jul 15, 2015, 12:17 AM EDT