jeudi 9 mai 2019

cell index to string

I have already tried to get the string of cell, but visual studio 2017 stop me while the program runs.

int sumphre = 0;

for (int i =0; i< dataGridViewWhouse.Rows.Count; i++)
{
    //here is the problem
    string outString = dataGridViewWhouse.Rows[dataGridViewWhouse.SelectedRows[i].Index]
                        .Cells[6]
                        .Value
                        .ToString();

    int length = outString.Length;
    if (length == 4)
    {
        sumphre += Convert.ToInt32(dataGridViewWhouse.Rows[i].Cells[7].Value);
    }
}

label4.Text = sumphre.ToString();

Aucun commentaire:

Enregistrer un commentaire