How to programmatically add a row to a datagridview when it is data-bound?
c#, datagridview
Solution
Add a row to the datatable, the datagridview will update automatically:
DataTable dt = myDataGridView.DataSource as DataTable;
//Create the new row
DataRow row = dt.NewRow();
//Populate the row with data
//Add the row to data table
dt.Rows.Add(row);
Problem
How can I add a row to a datagridview control if it is bounded to a datasource (datatable) ? Thanks!