just replace the code
for (int col = 0; col <= tableLayoutPanel1.ColumnCount - 1; col++)
{
for (int rows = 0; rows <= tableLayoutPanel1.RowCount - 1; rows++)
{
to
for (int rows = 0; rows <= tableLayoutPanel1.RowCount - 1; rows++)
{
for (int col = 0; col <= tableLayoutPanel1.ColumnCount - 1; col++)
{