CODE :
Imports System.Data
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim tb As New DataTable("stud")
Dim col As DataColumn
Dim row As DataRow
col = New DataColumn
col.DataType = GetType(Int32)
col.ColumnName = "id"
tb.Columns.Add(col)
col = New DataColumn
col.DataType = GetType(String)
col.ColumnName = "name"
tb.Columns.Add(col)
Dim i As Integer
For i = 0 To 5
row = tb.NewRow
row("id") = i
row("name") = "name" & i
tb.Rows.Add(row)
Next i
DataGridView1.DataSource = tb
End Sub
End Class
No comments:
Post a Comment