T
Tony Johansson
Hello!
I'm new to use this DataGridView.
I use a textfile to store my rows from the DataGridView
I have a DataGridView representing the DataTable.
When I push the Save Button I call the event handler below.
The DataGridView control is called dataGridViewWareHouse.
In my first attempt I didn't us a DataTable so the code I used to save my
DataGridView rows into
the textfile was to loop through the rows for the DataGridView and have a
code something like
//Start old code
string myAddedRow =
dataGridViewWareHouse.Rows[row].AccessibilityObject.Value;
string[] myRow = myAddedRow.Split(new char[] { ';' });
Product myProduct = new Product(myRow[(int)columnType.Name],
int.Parse(myRow[(int)columnType.Price]),
int.Parse(myRow[(int)columnType.ProductNummer]),
int.Parse(myRow[(int)columnType.Count]),
myRow[(int)columnType.Type]);
FileManager.Save(myProduct);
//end old code
I just wonder when I now use a DataTable which I call _dataTable how
would I write now to get the whole row from the DataTable or should
I still read the dataGridViewWareHouse ?
private void BtnSave_Click(object sender, EventArgs e)
{
foreach (DataRow dr in _dataTable.Rows)
{
if (dr.RowState == DataRowState.Added)
{
}
else if (dr.RowState = DataRowState.Unchanged)
continue;
}
}
//Tony
I'm new to use this DataGridView.
I use a textfile to store my rows from the DataGridView
I have a DataGridView representing the DataTable.
When I push the Save Button I call the event handler below.
The DataGridView control is called dataGridViewWareHouse.
In my first attempt I didn't us a DataTable so the code I used to save my
DataGridView rows into
the textfile was to loop through the rows for the DataGridView and have a
code something like
//Start old code
string myAddedRow =
dataGridViewWareHouse.Rows[row].AccessibilityObject.Value;
string[] myRow = myAddedRow.Split(new char[] { ';' });
Product myProduct = new Product(myRow[(int)columnType.Name],
int.Parse(myRow[(int)columnType.Price]),
int.Parse(myRow[(int)columnType.ProductNummer]),
int.Parse(myRow[(int)columnType.Count]),
myRow[(int)columnType.Type]);
FileManager.Save(myProduct);
//end old code
I just wonder when I now use a DataTable which I call _dataTable how
would I write now to get the whole row from the DataTable or should
I still read the dataGridViewWareHouse ?
private void BtnSave_Click(object sender, EventArgs e)
{
foreach (DataRow dr in _dataTable.Rows)
{
if (dr.RowState == DataRowState.Added)
{
}
else if (dr.RowState = DataRowState.Unchanged)
continue;
}
}
//Tony