grid[col, row] = c;
- for (int i = 1; i < col_span; i++)
- grid[col + i, row] = dummy_control;
-
- for (int i = 1; i < row_span; i++)
- grid[col, row + i] = dummy_control;
+ // Fill in the rest of this control's row/column extent with dummy
+ // controls, so that other controls don't get put there.
+ for (int i = 0; i < col_span; i++)
+ for (int j = 0; j < row_span; j++)
+ if (i != 0 || j != 0)
+ grid[col + i, row + j] = dummy_control;
}
}
}
grid[x, y] = c;
- for (int i = 1; i < col_span; i++)
- grid[x + i, y] = dummy_control;
-
- for (int i = 1; i < row_span; i++)
- grid[x, y + i] = dummy_control;
+ // Fill in the rest of this control's row/column extent with dummy
+ // controls, so that other controls don't get put there.
+ for (int i = 0; i < col_span; i++)
+ for (int j = 0; j < row_span; j++)
+ if (i != 0 || j != 0)
+ grid[x + i, y + j] = dummy_control;
// I know someone will kill me for using a goto, but
// sometimes they really are the easiest way...
Assert.AreEqual (0, p.LayoutSettings.RowCount, "C3");\r
}\r
\r
+ [Test]\r
+ public void TestCellPositioning18 ()\r
+ {\r
+ // A control with both rowspan and columnspan > 1 was getting\r
+ // other controls put into its extent (i.e. c3 was ending up\r
+ // at (1,1) instead of (2,1).\r
+ TableLayoutPanel p = new TableLayoutPanel ();\r
+ Control c1 = new Button ();\r
+ Control c2 = new Button ();\r
+ Control c3 = new Button ();\r
+ Control c4 = new Button ();\r
+\r
+ p.ColumnCount = 3;\r
+ p.RowCount = 4;\r
+\r
+ p.SetRowSpan (c1, 2);\r
+ p.SetColumnSpan (c1, 2);\r
+ p.SetCellPosition (c1, new TableLayoutPanelCellPosition (0, 0));\r
+\r
+ p.Controls.Add (c1);\r
+ p.Controls.Add (c2);\r
+ p.Controls.Add (c3);\r
+ p.Controls.Add (c4);\r
+\r
+ Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");\r
+ Assert.AreEqual (new TableLayoutPanelCellPosition (2, 0), p.GetPositionFromControl (c2), "C2");\r
+ Assert.AreEqual (new TableLayoutPanelCellPosition (2, 1), p.GetPositionFromControl (c3), "C3");\r
+ Assert.AreEqual (new TableLayoutPanelCellPosition (0, 2), p.GetPositionFromControl (c4), "C4");\r
+ }\r
+\r
[Test]\r
public void TestRowColumnSizes1 ()\r
{\r