In this article I will explain how to dynamically populate (bind) DataGridView without using Database in Windows Forms (WinForms) Application using C# and VB.Net
 
 
Form Controls
The below Form consists of a DataGridView control.
Populate (Bind) DataGridView without using Database in Windows Forms (WinForms) Application using C# and VB.Net
 
 
Populating DataGridView
Inside the Form Load event, a dynamic DataTable is created and some columns are added to it. Then some dummy records are added to the dynamic DataTable.
Finally the dynamic DataTable is used to populate the DataGridView control.

C#
private void Form1_Load(object sender, EventArgs e)
{
    this.BindDataGridView();
}
 
private void BindDataGridView()
{
    DataTable dt = new DataTable();
    dt.Columns.AddRange(new DataColumn[3] { new DataColumn("Id", typeof(int)),
                                new DataColumn("Name", typeof(string)),
                                new DataColumn("Country",typeof(string)) });
    dt.Rows.Add(1, "John Hammond", "United States");
    dt.Rows.Add(2, "Mudassar Khan", "India");
    dt.Rows.Add(3, "Suzanne Mathews", "France");
    dt.Rows.Add(4, "Robert Schidner", "Russia");
    this.dataGridView1.DataSource = dt;
}
 
VB.Net
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    BindDataGridView()
End Sub
 
Private Sub BindDataGridView()
    Dim dt As New DataTable()
    dt.Columns.AddRange(New DataColumn(2) {New DataColumn("Id", GetType(Integer)), New DataColumn("Name", GetType(String)), New DataColumn("Country", GetType(String))})
    dt.Rows.Add(1, "John Hammond", "United States")
    dt.Rows.Add(2, "Mudassar Khan", "India")
    dt.Rows.Add(3, "Suzanne Mathews", "France")
    dt.Rows.Add(4, "Robert Schidner", "Russia")
    Me.dataGridView1.DataSource = dt
End Sub
 
 
Screenshot
Populate (Bind) DataGridView without using Database in Windows Forms (WinForms) Application using C# and VB.Net
 
 
Downloads