VB.NET - How To Load Datatable Data To DataGridView Using VB.NET
In This VB.NET Tutorial We Will See How To Populate a DataGridView From DataTable Using VB.NET Programming Language.
Project Source Code:
Imports System.Data.DataTable
Public Class Bind_DatagridView_Wth_DataTable
' Create a new datatable
Dim table As New DataTable("Table")
Private Sub Bind_DatagridView_Wth_DataTable_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' Add columns to your datatable,
' with the name of the columns and their type
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"))
' Add rows to the datatable with some data
table.Rows.Add(1, "XXXX", "YYYYY", 21)
table.Rows.Add(2, "SSDD", "hGSQ", 33)
table.Rows.Add(3, "fgfgd", "jgfdd", 53)
table.Rows.Add(4, "cvfghyghj", "sdrgtyh", 19)
table.Rows.Add(5, "hghfd", "ghjgdf", 36)
table.Rows.Add(6, "cvvdfgh", "juyrfdvc", 63)
' now set the datagridview datasource equals to your datatable name
DataGridView1.DataSource = table
End Sub
End Class
///////////////OUTPUT:
VB.NET - Fill DataGridView Using DataTable
Bagikan
VB.NET - How To Bind DataGridView Using Datatable
4/
5
Oleh
insurance