I hope this helps.
A better approach is to use the
DataSet
as a data source for the
DataGridView
.
1. Create a DataSet as a private member of your class.
private DataSet dsIsland = new DataSet("DataSetIsland");
2. In FormLoad create a
DataTable
and add the columns you want.
DataTable dt = dsIsland.Tables.Add("Island");
DataColumn dcSelect = dt.Columns.Add("Select", typeof(bool));
DataColumn dcIsland = dt.Columns.Add("Island", typeof(string));
DataColumn dcPortConfig = dt.Columns.Add("PortConfig", typeof(string));
DataColumn dcSetupFile = dt.Columns.Add("SetupFile", typeof(string));
DataColumn dcSettingsFile = dt.Columns.Add("SettingsFile", typeof(string));
3. Set default values to some columns
dcSelect.DefaultValue = false;
What other columns need default values?
4. Connct the
DataSet
to the
DataGridView
dgvIsland.DataSource = dsIsland;
dgvIsland.DataMember = dt.TableName;
Inside your existing method
private void createXML(string filename)
{
dsIsland.AcceptChanges();
dsIsland.WriteXml(filename);
}