T
Tony Johansson
Hello!
I have a DataGridView with 5 columns and a save button that I use to save
the contens to a textFile.
Everything works fine I can enter value in the columns and then save to a
textfile by clicking on the Save button.
Below is the event handler for the save button
The dataGridView is called dgLager
_rowIndexHit is a genering List instance with ints where a store all row
index that I have clicked in.
In the text file a store the last productnumber that I have in the textfile.
I get that last productnumber used by calling
FileManager.UpdateProductNumber.
This ValidateMyRow method just check if every cell in a row has been given a
value
I have a class called Product which is used to hold products like book, DVD
and games and such things.
I save to the textfile by calling Save on the static class FileManager.
Now to my question I wonder what I can do to find out if a row in a
DataGridView has been changed.?
I want some suggestions what I can do.
I must say that I have more to do on this DataGridView functionality because
I haven't started
yet with the function to read textfile and fill the DataGridVies with the
text file contents.
private void BtnProductSave_Click(object sender, EventArgs e)
{
if (_rowIndexHit.Count > 0)
FileManager.UpdateProductNumber(_currentProductNumber.ToString());
foreach (int row in _rowIndexHit)
{
string myAddedRow = dgLager.Rows[row].AccessibilityObject.Value;
string[] myRow = myAddedRow.Split(new char[] { ';' });
if (!ValidateMyRow(myRow))
{
MessageBox.Show(this,"All values in a row must be entered",
"Validating Input",MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
//enum columnType { Namn, Pris, Produktnummer, Antal, Typ };
Product myProduct = new Product(myRow[(int)columnType.Namn],
int.Parse(myRow[(int)columnType.Pris]),
int.Parse(myRow[(int)columnType.Produktnummer]),
int.Parse(myRow[(int)columnType.Antal]),
myRow[(int)columnType.Typ]);
FileManager.Save(myProduct);
}
_rowIndexHit.Clear();
}
//Tony
I have a DataGridView with 5 columns and a save button that I use to save
the contens to a textFile.
Everything works fine I can enter value in the columns and then save to a
textfile by clicking on the Save button.
Below is the event handler for the save button
The dataGridView is called dgLager
_rowIndexHit is a genering List instance with ints where a store all row
index that I have clicked in.
In the text file a store the last productnumber that I have in the textfile.
I get that last productnumber used by calling
FileManager.UpdateProductNumber.
This ValidateMyRow method just check if every cell in a row has been given a
value
I have a class called Product which is used to hold products like book, DVD
and games and such things.
I save to the textfile by calling Save on the static class FileManager.
Now to my question I wonder what I can do to find out if a row in a
DataGridView has been changed.?
I want some suggestions what I can do.
I must say that I have more to do on this DataGridView functionality because
I haven't started
yet with the function to read textfile and fill the DataGridVies with the
text file contents.
private void BtnProductSave_Click(object sender, EventArgs e)
{
if (_rowIndexHit.Count > 0)
FileManager.UpdateProductNumber(_currentProductNumber.ToString());
foreach (int row in _rowIndexHit)
{
string myAddedRow = dgLager.Rows[row].AccessibilityObject.Value;
string[] myRow = myAddedRow.Split(new char[] { ';' });
if (!ValidateMyRow(myRow))
{
MessageBox.Show(this,"All values in a row must be entered",
"Validating Input",MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
//enum columnType { Namn, Pris, Produktnummer, Antal, Typ };
Product myProduct = new Product(myRow[(int)columnType.Namn],
int.Parse(myRow[(int)columnType.Pris]),
int.Parse(myRow[(int)columnType.Produktnummer]),
int.Parse(myRow[(int)columnType.Antal]),
myRow[(int)columnType.Typ]);
FileManager.Save(myProduct);
}
_rowIndexHit.Clear();
}
//Tony