Vb.net 如何手动向datagrid添加新行
如何手动向datagrid添加新行?您不应该向datagrid添加行。您应该向绑定到datagrid的对象(集合、datatable)添加行Vb.net 如何手动向datagrid添加新行,vb.net,Vb.net,如何手动向datagrid添加新行?您不应该向datagrid添加行。您应该向绑定到datagrid的对象(集合、datatable)添加行 DataTable dt = new DataTable(); dt.Columns.Add("Name"); dt.Rows.Add(new[]{"John"}) datagrid.DataSource = dt; //Adding new rows - simply paste this code into (for example) button c
DataTable dt = new DataTable();
dt.Columns.Add("Name");
dt.Rows.Add(new[]{"John"})
datagrid.DataSource = dt;
//Adding new rows - simply paste this code into (for example) button click event handler
dt.Rows.Add(new[]{"New John"})
//And you should be able to see new row added to grid
此外,还有许多支持非绑定模式的商业网格。需要更多。显示一些代码。