Minggu, 13 Maret 2016

VB.NET - How To Add A Row To DataGridView From InputBox In VB.NET

vb add row to datagridview

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:
add row to datagridview using inputbox
vb.net add row to datagridview using inputbox

Bagikan

Jangan lewatkan

VB.NET - How To Add A Row To DataGridView From InputBox In VB.NET
4/ 5
Oleh

Subscribe via email

Suka dengan artikel di atas? Tambahkan email Anda untuk berlangganan.