How to load <list> data into dataGridView in c#

I already have rows and columns for dataGridView in c# widows form application. How can I display the data into `datagridview..whole the data are in a list. Now, I want to load the list into datagridview.. I am new to c# and would appreciate any help.


sounds like you want to use a list as the datasource.

List<myObject> oblst = new List<myObject>;
//insert into the list
datagridview.DataSource = oblst;

Removed datagridview.DataBind();


In your question you didn't mention which type of list you use. Try to do this using data table.

DataTable dt = new DataTable();
dt.Columns.Add("FirstName");
dt.Columns.Add("LastName");
foreach(var oItem in YourList)
{
     dt.Rows.Add(new object[] { oItem.FirstName, oItem.LastName });
}
myDataGridView.DataSource = dt;