I want to add rows to a datagridview
. I tried a lot of possibilities, but it doesn't appear anything on it. I think the best solution is to create a datatable, and then to use it as datasource for my gridview. I use winforms. Please, any other idea is welcomed . This is what I have tried so far:
public DataTable GetResultsTable()
{
DataTable table = new DataTable();
table.Columns.Add("Name".ToString());
table.Columns.Add("Color".ToString());
DataRow dr;
dr = table.NewRow();
dr["Name"] = "Mike";
dr["Color "] = "blue";
table.AcceptChanges();
return table;
}
public void gridview()
{
datagridview1.DataSource=null;
datagridview1.DataSource=table;
}