Convert from grid to array

0

I have a dataGridView1 with 3 columns name, amount and price I need to take them to the following format

000000010000001000Papas 

where:

  

(0000000100) (00001000) (Popes)

The first is the price, the second the quantity and the third the name.

    
asked by Gilberto Asuaje 11.10.2016 в 06:39
source

2 answers

2

I have not tried it, but I think something like this could work:

        foreach (DataGridViewRow item in dataGridView1.Rows)
        {
            string datos = "";
            foreach (DataGridViewCell item2 in item.Cells)
            {
                datos += item2.Value.ToString();
            }
            //y aqui ya haces lo que quieras con el string
        }
    
answered by 11.10.2016 / 18:07
source
0

You could try like this (I have not tried the code):

string resultado = string.Empty;
foreach (DataGridViewRow item in dataGridView1.Rows)
{
    resultado += "(" + item["nombre"].text + item["cantidad"].text + item["precio"].text + ")";
}
    
answered by 11.10.2016 в 19:14