DataGridView - read all values of the cells into arrays

Answered DataGridView - read all values of the cells into arrays

  • Thursday, June 28, 2012 3:18 PM
     
     

    hi experts,

    I am new in programming , I want save the value of rows and columns of a table into a .txt file .

    actually I want read all rows from first to end and save this values into variables(arrays and .....) I don't know how can do it ,

    there is a way that I can specify the values of cells  of the table

    as a result I want to know:

    how can get the value of cells of the table and save them to arrays or another suitable variables ?

    thanks so much in advance !


    Reza Naghavi

All Replies

  • Thursday, June 28, 2012 8:45 PM
     
     Answered

    i solve it with this:

    http://stackoverflow.com/questions/6487839/how-can-i-read-data-from-datagridview-c


    Reza Naghavi

    • Marked As Answer by Mr.Reza Thursday, June 28, 2012 8:45 PM
    •  
  • Thursday, June 28, 2012 8:47 PM
     
     Answered
     str = new string[100];
                int count = 0;

                for (int row = 0; row < dataGridView1.RowCount-1; row++)
                {
                    for (int col = 0; col < dataGridView1.Rows[row].Cells.Count; col++)
                    {
                        str[count++] = dataGridView1.Rows[row].Cells[col].Value.ToString();
                    }
                }  

    Reza Naghavi

    • Marked As Answer by Mr.Reza Thursday, June 28, 2012 8:48 PM
    •