I have a datagrid DGV. That gridview has a column of "File Name" and is populated by the name of the files you've selected in an openfildialog. After performing the calculations I was putting the results in a second datagrid DGV2 which you'll see I've commented out below as I'd like to instead put them on a second column next to their corresponding "File Name" on DGV and just use one gridview. However this is just taking the last calculation and duplicating it on each row rather than the individual calculations (as they should all be diff)
So it should look like:
File1 4.5
File2 3.5
Instead its just doing
File1 3.5
File2 3.5
I know I'm causing it, I've done something wrong here I'm just not sure how to fix it.
private void btnCalculate_Click(object sender, EventArgs e)
{
foreach (DataGridViewRow row in DGV_Hidden.Rows)
{
FileInfo info = new FileInfo();
{
var lines = File.ReadAllLines(row.Cells["colfilelocation"].Value.ToString());
var data = lines.Where(line => (!line.Contains(Data_Start_Point_Identifier) && !line.Contains(FSD__Line_Identifier) && !line.EndsWith("0.00"))).ToList();
if (data.Count > 1)
{
var line = data[0];
var firstsplit = data[1].Split(splitter);
info.startvalue = Convert.ToDouble(firstsplit[0]);
var secondsplit = data[data.Count - 1].Split(splitter);
info.endvalue = Convert.ToDouble(secondsplit[0]);
}
info.finalnum = info.startvalue - info.endvalue;
}
//DGV2.Rows.Add(info.finalnum);
for (int i = 0; i < DGV.Rows.Count; i++)
{
DGV.Rows[i].Cells["colfiledata"].Value = info.finalnum;
}
}
}
info.finalnumof that last file. I think you only want to set for that particular file, not all.