i have a windows form where i am trying to add the path of a file usnig folderbrowserDialog
i have this code on at form load
public FileMgmt()
{
InitializeComponent();
//
// Here we create a DataTable with four columns.
//
DataTable table = new DataTable();
table.Columns.Add("Check", typeof(bool));
table.Columns.Add("Path", typeof(string));
table.Columns.Add("Date", typeof(DateTime));
table.Rows.Add(false, "", DateTime.Now);
dataGridView2.DataSource = table;
}
this is the code when i click a button to search for folders and add the path to the above gridview which already has the above row
private void AddPubPath_Button_Click(object sender, EventArgs e)
{
folderBrowserDialog1.ShowDialog();
dataGridView2.Rows.Add(false, folderBrowserDialog1.SelectedPath, DateTime.Now);
}
but i get the following error..
Rows cannot be programmatically added to the DataGridView's rows collection when the control is data-bound.
please, any suggestions