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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Syed ShanuPosted Jul 15, 2015, 4:35 AM
{
{
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);
}
Manoj BhoirPosted Jul 19, 2015, 9:09 AM
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.Govinda Rajulu YemineniPosted Jul 19, 2015, 8:28 AM
King UmarPosted Jul 15, 2015, 4:17 AM
Syed ShanuPosted Jul 15, 2015, 4:08 AM