I have a datagridview which displays values in an array. I would like the 5th column to show a string based on the data in the previous columns. I have a foreach loop as you can see but column 5 is still appearing blank. All help appreciated.
try
{
if (File.Exists("competitorDetailsFile.txt")) //if this
file exists
{
string[] detailsArray =
File.ReadLines("competitorDetailsFile.txt").ToArray(); //write data to
array
double time = 0;
double time1 = 0;
for (int number = 0; number < detailsArray.Length;
number++)
{
string[] detailsArray2 =
detailsArray[number].Split('~'); //split on tilda
time1 = Convert.ToDouble(detailsArray2[3]) +
Convert.ToDouble(detailsArray2[4]) + Convert.ToDouble(detailsArray2[5])
+ Convert.ToDouble(detailsArray2[6]) +
Convert.ToDouble(detailsArray2[7]);
time = time1 / 5;
int score = Convert.ToInt32(detailsArray2[8]);
//time is equal to the average of the ski times
dataGridView1.Rows.Add(detailsArray2[0],
Convert.ToDouble(detailsArray2[1]), Convert.ToInt32(detailsArray2[8]),
time);
{
foreach (DataGridViewRow row in
dataGridView1.Rows)
{
foreach (DataGridViewCell cell in
row.Cells)
{
if (time > 100)
{
row.Cells[5].Value = "LOW";
}
else if (time < 100)
{
row.Cells[5].Value = "HIGH";
}
}
}
}
Aucun commentaire:
Enregistrer un commentaire