我想将行添加到datagridview
. 我尝试了很多可能性,但它没有出现任何东西。我认为最好的解决方案是创建一个数据表,然后将其用作我的 gridview 的数据源。我使用winforms。请,欢迎任何其他想法。这是我到目前为止所尝试的:
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;
}