Example 5. Printing a table with repeating rows and columns

Top  Previous  Next

private void Table1_ManualBuild(object sender, EventArgs e)

{

  // --------- printing row 0

  Table1.PrintRow(0);

  // printing column 0

  Table1.PrintColumn(0);

  // printing 3 copies of column 1

  for (int i = 0; i < 3; i++)

    Table1.PrintColumn(1);

  // printing column 2

  Table1.PrintColumn(2);

  

  // --------- printing 3 copies of row 1

  for (int j = 0; j < 3; j++)

  {

    Table1.PrintRow(1);

    // printing column 0

    Table1.PrintColumn(0);

    // printing 3 copies of column 1

    for (int i = 0; i < 3; i++)

      Table1.PrintColumn(1);

    // printing column 2

    Table1.PrintColumn(2);

  }

 

  // --------- printing row 2

  Table1.PrintRow(2);

  // printing column 0

  Table1.PrintColumn(0);

  // printing 3 copies of column 1

  for (int i = 0; i < 3; i++)

    Table1.PrintColumn(1);

  // printing column 2

  Table1.PrintColumn(2);

}

 

Pay attention that we printed the same number of columns in every row. If this rule is violated, then we will get an unpredictable result.

 

In this example, the middle row and middle column of the table were printed 3 times. And as a result, we get the following:

 

tableExample5