VB.NET - How To Insert A Row To DataGridView Using InputBpx In VB.NET
In This VB.NET Tutorial We Will See How To Add a Row To DataGridView Using InputBox In VB.NET Programming Language.
Project Source Code:
Public Class VB_Add_Row_DataGridView_Using_InputBox
Dim table As New DataTable("Table")
Private Sub BtnAddRow_Click(sender As Object, e As EventArgs) Handles BtnAddRow.Click
' get data from input box
Dim id As Integer
id = Integer.Parse(InputBox("Enter The Id", "Row Data", -1, -1).ToString())
Dim fn As String
fn = InputBox("Enter The First Name", "Row Data", -1, -1)
Dim ln As String
ln = InputBox("Enter The Last Name", "Row Data", -1, -1).ToString()
Dim age As Integer
age = Integer.Parse(InputBox("Enter The Age", "Row Data", -1, -1).ToString())
' add row to datatable
table.Rows.Add(id, fn, ln, age)
End Sub
Private Sub VB_Add_Row_DataGridView_Using_InputBox_Load(sender As Object, e As EventArgs) Handles MyBase.Load
table.Columns.Add("Id", Type.GetType("System.Int32"))
table.Columns.Add("First Name", Type.GetType("System.String"))
table.Columns.Add("Last Name", Type.GetType("System.String"))
table.Columns.Add("Age", Type.GetType("System.Int32"))
DataGridView1.DataSource = table
End Sub
End Class
///////////////OUTPUT:
vb.net add row to datagridview using inputbox
2 comments
commentsHenry
ReplyYou are not a good Developer if you will sale code and no one can reach you no contact or email then you are a bad Developer
Reply