Hi All,
I have been trying this Since hours but not reaching anywhere.
I have a DataGridView which would fetch Values from the User and get updated at Runtime when he clicks the Save Button.
This Datagridview Contains Comboboxes and TextBoxes and to make things worst, the Inputs given by the User need to be saved as part of his Preferences.
Say He opens the Form, Provides an Input
A - Clicks Save Button, Closes the Form. Then again Reopens the Form, Input A should be reflected.
The below code just displays Blank Columns in the DatagridView, The no. of Rows increment according to the Rows created by the User, but no Data is populated.
I know, I must be missing a lot of things but just not able to crack it.
Here is what I have till now:
//Form Load
private void Preferences_Load(object sender, EventArgs e)
{
this.WorkflowGridView1.DataSource = Properties.Settings.Default.WorkflowData;
}
I was trying to Save the Datasource in the Application Settings->Property Binding
public void Save_Click(object sender, EventArgs e)
{
DTable = new DataTable();
SBind = new BindingSource();
for (int i = 0; i < WorkflowGridView1.ColumnCount; ++i)
{
DTable.Columns.Add(new DataColumn(WorkflowGridView1.Columns[i].Name));
WorkflowGridView1.Columns[i].DataPropertyName = WorkflowGridView1.Columns[i].Name;
}
foreach (DataGridViewRow row in WorkflowGridView1.Rows)
{
DataRow rw = DTable.NewRow();
rw["Technology"] = row.Cells[0].Value;
rw["Action"] = row.Cells[1].Value;
rw["Identifier"] = row.Cells[2].Value;
rw["Value"] = row.Cells[3].Value;
rw["UserInput"] = row.Cells[4].Value;
DTable.Rows.Add(rw);
}
SBind.DataSource = DTable;
WorkflowGridView1.DataSource = SBind;
Properties.Settings.Default.WorkflowData = DTable;
Properties.Settings.Default.Save();
this.Close();
}
P.S. I am looking out for a Solution through Application Settings only, Any help would be much appreciated.
Thanks
Sim