Well, this is easy:
for (int i = 0; i <= 8; i++) { Cell cell = new Cell(); panel.Controls.Add(cell); // ..... cell.Format(cell);
But, let's assume that the first half and the second half of that aren't in the same loop:
for (int i = 0; i <= 8; i++) { Cell cell = new Cell(); panel.Controls.Add(cell); } /// foreach(Cell cell in panel.Controls) { if (cell != null) // non-Cell control in panel will be null { cell.Format(cell); } }
|