I want to read all the data from a datagridview when a button is clicked and then put it in a listbox. I came this far but everytime It's not working and I don't know why. I have tried everything

This is my code:

```
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
    for (int j = 0; j < dataGridView1.Columns.Count; j++)
    {
        DataGridViewCell c = dataGridView1.Rows[i].Cells[j];
        if (c.Value != null)
        {
            listBox1.Items.Add(c.Value.ToString());
        }
    }                

```