2 // TableLayoutTests.cs
\r
4 // Permission is hereby granted, free of charge, to any person obtaining
\r
5 // a copy of this software and associated documentation files (the
\r
6 // "Software"), to deal in the Software without restriction, including
\r
7 // without limitation the rights to use, copy, modify, merge, publish,
\r
8 // distribute, sublicense, and/or sell copies of the Software, and to
\r
9 // permit persons to whom the Software is furnished to do so, subject to
\r
10 // the following conditions:
\r
12 // The above copyright notice and this permission notice shall be
\r
13 // included in all copies or substantial portions of the Software.
\r
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
\r
18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
\r
19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
\r
20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
\r
21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
23 // Copyright (c) 2006 Jonathan Pobst
\r
26 // Jonathan Pobst (monkey@jpobst.com)
\r
31 using System.Drawing;
\r
32 using System.Windows.Forms;
\r
33 using NUnit.Framework;
\r
35 namespace MonoTests.System.Windows.Forms
\r
38 public class TableLayoutTests
\r
41 public void TestConstruction ()
\r
43 TableLayoutPanel p = new TableLayoutPanel ();
\r
45 Assert.AreEqual (BorderStyle.None, p.BorderStyle, "A1");
\r
46 Assert.AreEqual (TableLayoutPanelCellBorderStyle.None, p.CellBorderStyle, "A2");
\r
47 Assert.AreEqual (0, p.ColumnCount, "A3");
\r
48 Assert.AreEqual (TableLayoutPanelGrowStyle.AddRows, p.GrowStyle, "A4");
\r
49 Assert.AreEqual ("System.Windows.Forms.Layout.TableLayout", p.LayoutEngine.ToString (), "A5");
\r
50 Assert.AreEqual ("System.Windows.Forms.TableLayoutSettings", p.LayoutSettings.ToString (), "A6");
\r
51 Assert.AreEqual (0, p.RowCount, "A7");
\r
52 Assert.AreEqual (0, p.ColumnStyles.Count, "A8");
\r
53 Assert.AreEqual (0, p.RowStyles.Count, "A9");
\r
54 Assert.AreEqual (new Size (200, 100), p.Size, "A10");
\r
58 public void TestPropertySetters ()
\r
60 TableLayoutPanel p = new TableLayoutPanel ();
\r
62 p.BorderStyle = BorderStyle.Fixed3D;
\r
63 p.CellBorderStyle = TableLayoutPanelCellBorderStyle.OutsetDouble;
\r
65 p.GrowStyle = TableLayoutPanelGrowStyle.FixedSize;
\r
68 Assert.AreEqual (BorderStyle.Fixed3D, p.BorderStyle, "A1");
\r
69 Assert.AreEqual (TableLayoutPanelCellBorderStyle.OutsetDouble, p.CellBorderStyle, "A2");
\r
70 Assert.AreEqual (1, p.ColumnCount, "A3");
\r
71 Assert.AreEqual (TableLayoutPanelGrowStyle.FixedSize, p.GrowStyle, "A4");
\r
72 Assert.AreEqual (1, p.RowCount, "A7");
\r
76 public void TestExtenderMethods ()
\r
78 TableLayoutPanel p = new TableLayoutPanel ();
\r
79 Control c = new Button ();
\r
81 Assert.AreEqual (new TableLayoutPanelCellPosition (-1, -1), p.GetCellPosition (c), "A1");
\r
82 Assert.AreEqual (-1, p.GetColumn (c), "A2");
\r
83 Assert.AreEqual (1, p.GetColumnSpan (c), "A3");
\r
84 Assert.AreEqual (-1, p.GetRow (c), "A4");
\r
85 Assert.AreEqual (1, p.GetRowSpan (c), "A5");
\r
87 p.SetCellPosition (c, new TableLayoutPanelCellPosition (1, 1));
\r
88 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 1), p.GetCellPosition (c), "A6");
\r
91 Assert.AreEqual (2, p.GetColumn (c), "A7");
\r
93 Assert.AreEqual (2, p.GetRow (c), "A9");
\r
95 p.SetColumnSpan (c, 2);
\r
96 Assert.AreEqual (2, p.GetColumnSpan (c), "A8");
\r
99 p.SetRowSpan (c, 2);
\r
100 Assert.AreEqual (2, p.GetRowSpan (c), "A10");
\r
102 Assert.AreEqual (new TableLayoutPanelCellPosition (2, 2), p.GetCellPosition (c), "A11");
\r
105 //Assert.AreEqual (new TableLayoutPanelCellPosition (-1, -1), p.GetPositionFromControl (c), "A12");
\r
106 //Assert.AreEqual (c, p.GetControlFromPosition(0, 0), "A13");
\r
110 public void TestColumnStyles ()
\r
112 TableLayoutPanel p = new TableLayoutPanel ();
\r
114 p.ColumnStyles.Add (new ColumnStyle ());
\r
115 p.ColumnStyles.Add (new ColumnStyle (SizeType.Absolute));
\r
116 p.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 20F));
\r
118 Assert.AreEqual (3, p.ColumnStyles.Count, "A1");
\r
119 Assert.AreEqual (SizeType.AutoSize, p.ColumnStyles[0].SizeType, "A2");
\r
120 Assert.AreEqual (0, p.ColumnStyles[0].Width, "A3");
\r
121 Assert.AreEqual (SizeType.Absolute, p.ColumnStyles[1].SizeType, "A4");
\r
122 Assert.AreEqual (0, p.ColumnStyles[1].Width, "A5");
\r
123 Assert.AreEqual (SizeType.Percent, p.ColumnStyles[2].SizeType, "A6");
\r
124 Assert.AreEqual (20F, p.ColumnStyles[2].Width, "A7");
\r
126 p.ColumnStyles.Remove (p.ColumnStyles[0]);
\r
128 Assert.AreEqual (2, p.ColumnStyles.Count, "A8");
\r
129 Assert.AreEqual (SizeType.Absolute, p.ColumnStyles[0].SizeType, "A9");
\r
130 Assert.AreEqual (0, p.ColumnStyles[0].Width, "A10");
\r
131 Assert.AreEqual (SizeType.Percent, p.ColumnStyles[1].SizeType, "A11");
\r
132 Assert.AreEqual (20F, p.ColumnStyles[1].Width, "A12");
\r
136 public void TestRowStyles ()
\r
138 TableLayoutPanel p = new TableLayoutPanel ();
\r
140 p.RowStyles.Add (new RowStyle ());
\r
141 p.RowStyles.Add (new RowStyle (SizeType.Absolute));
\r
142 p.RowStyles.Add (new RowStyle (SizeType.Percent, 20F));
\r
144 Assert.AreEqual (3, p.RowStyles.Count, "A1");
\r
145 Assert.AreEqual (SizeType.AutoSize, p.RowStyles[0].SizeType, "A2");
\r
146 Assert.AreEqual (0, p.RowStyles[0].Height, "A3");
\r
147 Assert.AreEqual (SizeType.Absolute, p.RowStyles[1].SizeType, "A4");
\r
148 Assert.AreEqual (0, p.RowStyles[1].Height, "A5");
\r
149 Assert.AreEqual (SizeType.Percent, p.RowStyles[2].SizeType, "A6");
\r
150 Assert.AreEqual (20F, p.RowStyles[2].Height, "A7");
\r
152 p.RowStyles.Remove (p.RowStyles[0]);
\r
154 Assert.AreEqual (2, p.RowStyles.Count, "A8");
\r
155 Assert.AreEqual (SizeType.Absolute, p.RowStyles[0].SizeType, "A9");
\r
156 Assert.AreEqual (0, p.RowStyles[0].Height, "A10");
\r
157 Assert.AreEqual (SizeType.Percent, p.RowStyles[1].SizeType, "A11");
\r
158 Assert.AreEqual (20F, p.RowStyles[1].Height, "A12");
\r
162 public void TestColumnStyles3 ()
\r
164 // Don't lose the 2nd style
\r
165 TableLayoutPanel p = new TableLayoutPanel ();
\r
168 p.ColumnStyles.Add (new ColumnStyle (SizeType.Absolute, 20F));
\r
169 p.ColumnStyles.Add (new ColumnStyle (SizeType.Absolute, 20F));
\r
173 Assert.AreEqual (2, p.ColumnStyles.Count, "A1");
\r
177 public void TestColumnStyles2 ()
\r
179 // Don't lose the 2nd style
\r
180 TableLayoutPanel p = new TableLayoutPanel ();
\r
183 p.ColumnStyles.Add (new ColumnStyle (SizeType.Absolute, 20F));
\r
187 Assert.AreEqual (1, p.ColumnStyles.Count, "A2");
\r
191 public void TestCellPositioning ()
\r
194 TableLayoutPanel p = new TableLayoutPanel ();
\r
195 Control c1 = new Button ();
\r
196 Control c2 = new Button ();
\r
197 Control c3 = new Button ();
\r
198 Control c4 = new Button ();
\r
203 p.Controls.Add (c1);
\r
204 p.Controls.Add (c2);
\r
205 p.Controls.Add (c3);
\r
206 p.Controls.Add (c4);
\r
208 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
\r
209 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 0), p.GetPositionFromControl (c2), "C2");
\r
210 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c3), "C3");
\r
211 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 1), p.GetPositionFromControl (c4), "C4");
\r
215 public void TestCellPositioning2 ()
\r
217 // Growstyle = Add Rows
\r
218 TableLayoutPanel p = new TableLayoutPanel ();
\r
219 Control c1 = new Button ();
\r
220 Control c2 = new Button ();
\r
221 Control c3 = new Button ();
\r
222 Control c4 = new Button ();
\r
223 Control c5 = new Button ();
\r
224 Control c6 = new Button ();
\r
229 p.Controls.Add (c1);
\r
230 p.Controls.Add (c2);
\r
231 p.Controls.Add (c3);
\r
232 p.Controls.Add (c4);
\r
233 p.Controls.Add (c5);
\r
234 p.Controls.Add (c6);
\r
236 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
\r
237 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 0), p.GetPositionFromControl (c2), "C2");
\r
238 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c3), "C3");
\r
239 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 1), p.GetPositionFromControl (c4), "C4");
\r
240 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 2), p.GetPositionFromControl (c5), "C5");
\r
241 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 2), p.GetPositionFromControl (c6), "C6");
\r
245 public void TestCellPositioning3 ()
\r
247 // Growstyle = Add Columns
\r
248 TableLayoutPanel p = new TableLayoutPanel ();
\r
249 p.GrowStyle = TableLayoutPanelGrowStyle.AddColumns;
\r
251 Control c1 = new Button ();
\r
252 Control c2 = new Button ();
\r
253 Control c3 = new Button ();
\r
254 Control c4 = new Button ();
\r
255 Control c5 = new Button ();
\r
256 Control c6 = new Button ();
\r
261 p.Controls.Add (c1);
\r
262 p.Controls.Add (c2);
\r
263 p.Controls.Add (c3);
\r
264 p.Controls.Add (c4);
\r
265 p.Controls.Add (c5);
\r
266 p.Controls.Add (c6);
\r
268 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
\r
269 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 0), p.GetPositionFromControl (c2), "C2");
\r
270 Assert.AreEqual (new TableLayoutPanelCellPosition (2, 0), p.GetPositionFromControl (c3), "C3");
\r
271 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c4), "C4");
\r
272 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 1), p.GetPositionFromControl (c5), "C5");
\r
273 Assert.AreEqual (new TableLayoutPanelCellPosition (2, 1), p.GetPositionFromControl (c6), "C6");
\r
277 [ExpectedException (typeof (ArgumentException))]
\r
278 public void TestCellPositioning4 ()
\r
280 // Growstyle = Fixed Size
\r
281 TableLayoutPanel p = new TableLayoutPanel ();
\r
282 p.GrowStyle = TableLayoutPanelGrowStyle.FixedSize;
\r
284 Control c1 = new Button ();
\r
285 Control c2 = new Button ();
\r
286 Control c3 = new Button ();
\r
287 Control c4 = new Button ();
\r
288 Control c5 = new Button ();
\r
293 p.Controls.Add (c1);
\r
294 p.Controls.Add (c2);
\r
295 p.Controls.Add (c3);
\r
296 p.Controls.Add (c4);
\r
297 p.Controls.Add (c5);
\r
301 public void TestCellPositioning5 ()
\r
303 // One control have fixed position
\r
304 TableLayoutPanel p = new TableLayoutPanel ();
\r
305 Control c1 = new Button ();
\r
306 Control c2 = new Button ();
\r
307 Control c3 = new Button ();
\r
308 Control c4 = new Button ();
\r
313 p.SetCellPosition (c4, new TableLayoutPanelCellPosition (0, 0));
\r
315 p.Controls.Add (c1);
\r
316 p.Controls.Add (c2);
\r
317 p.Controls.Add (c3);
\r
318 p.Controls.Add (c4);
\r
320 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c4), "C1");
\r
321 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 0), p.GetPositionFromControl (c1), "C2");
\r
322 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c2), "C3");
\r
323 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 1), p.GetPositionFromControl (c3), "C4");
\r
327 public void TestCellPositioning6 ()
\r
329 // One control has fixed column, it should be ignored
\r
330 TableLayoutPanel p = new TableLayoutPanel ();
\r
331 Control c1 = new Button ();
\r
332 Control c2 = new Button ();
\r
333 Control c3 = new Button ();
\r
334 Control c4 = new Button ();
\r
339 p.SetColumn (c3, 1);
\r
341 p.Controls.Add (c1);
\r
342 p.Controls.Add (c2);
\r
343 p.Controls.Add (c3);
\r
344 p.Controls.Add (c4);
\r
346 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
\r
347 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 0), p.GetPositionFromControl (c2), "C2");
\r
348 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c3), "C3");
\r
349 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 1), p.GetPositionFromControl (c4), "C4");
\r
353 public void TestCellPositioning7 ()
\r
355 // One control has fixed column and row
\r
356 TableLayoutPanel p = new TableLayoutPanel ();
\r
357 Control c1 = new Button ();
\r
358 Control c2 = new Button ();
\r
359 Control c3 = new Button ();
\r
360 Control c4 = new Button ();
\r
365 p.SetColumn (c3, 1);
\r
368 p.Controls.Add (c1);
\r
369 p.Controls.Add (c2);
\r
370 p.Controls.Add (c3);
\r
371 p.Controls.Add (c4);
\r
373 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
\r
374 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 0), p.GetPositionFromControl (c2), "C2");
\r
375 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 1), p.GetPositionFromControl (c3), "C3");
\r
376 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c4), "C4");
\r
380 public void TestCellPositioning8 ()
\r
383 TableLayoutPanel p = new TableLayoutPanel ();
\r
384 Control c1 = new Button ();
\r
385 Control c2 = new Button ();
\r
386 Control c3 = new Button ();
\r
391 p.SetColumnSpan (c1, 2);
\r
393 p.Controls.Add (c1);
\r
394 p.Controls.Add (c2);
\r
395 p.Controls.Add (c3);
\r
397 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
\r
398 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c2), "C2");
\r
399 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 1), p.GetPositionFromControl (c3), "C3");
\r
403 public void TestCellPositioning9 ()
\r
406 TableLayoutPanel p = new TableLayoutPanel ();
\r
407 Control c1 = new Button ();
\r
408 Control c2 = new Button ();
\r
409 Control c3 = new Button ();
\r
414 p.SetRowSpan (c1, 2);
\r
416 p.Controls.Add (c1);
\r
417 p.Controls.Add (c2);
\r
418 p.Controls.Add (c3);
\r
420 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
\r
421 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 0), p.GetPositionFromControl (c2), "C2");
\r
422 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 1), p.GetPositionFromControl (c3), "C3");
\r
426 public void TestCellPositioning10 ()
\r
428 // Column span = 2, but control is in the last column, forces control back into 1st column, next row
\r
429 // I have no clue why c3 shouldn't be in (1,0), but MS says it's not
\r
430 TableLayoutPanel p = new TableLayoutPanel ();
\r
431 Control c1 = new Button ();
\r
432 Control c2 = new Button ();
\r
433 Control c3 = new Button ();
\r
438 p.SetColumnSpan (c2, 2);
\r
440 p.Controls.Add (c1);
\r
441 p.Controls.Add (c2);
\r
442 p.Controls.Add (c3);
\r
444 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
\r
445 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c2), "C2");
\r
446 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 2), p.GetPositionFromControl (c3), "C3");
\r
450 public void TestCellPositioning11 ()
\r
452 // Row span = 2, but control is in the last row, creates new row
\r
453 TableLayoutPanel p = new TableLayoutPanel ();
\r
454 Control c1 = new Button ();
\r
455 Control c2 = new Button ();
\r
456 Control c3 = new Button ();
\r
461 p.SetRowSpan (c3, 2);
\r
463 p.Controls.Add (c1);
\r
464 p.Controls.Add (c2);
\r
465 p.Controls.Add (c3);
\r
467 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
\r
468 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 0), p.GetPositionFromControl (c2), "C2");
\r
469 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c3), "C3");
\r
473 public void TestCellPositioning12 ()
\r
475 // Requesting a column greater than ColumnCount, request is ignored
\r
476 TableLayoutPanel p = new TableLayoutPanel ();
\r
477 Control c1 = new Button ();
\r
478 Control c2 = new Button ();
\r
479 Control c3 = new Button ();
\r
484 p.SetColumn (c1, 4);
\r
486 p.Controls.Add (c1);
\r
487 p.Controls.Add (c2);
\r
488 p.Controls.Add (c3);
\r
490 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
\r
491 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 0), p.GetPositionFromControl (c2), "C2");
\r
492 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c3), "C3");
\r
496 public void TestCellPositioning13 ()
\r
498 // Row span = 2, but control is in the last row, creates new row
\r
499 TableLayoutPanel p = new TableLayoutPanel ();
\r
500 Control c1 = new Button ();
\r
501 Control c2 = new Button ();
\r
502 Control c3 = new Button ();
\r
507 p.SetRowSpan (c3, 2);
\r
509 p.Controls.Add (c1);
\r
510 p.Controls.Add (c2);
\r
511 p.Controls.Add (c3);
\r
513 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
\r
514 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 0), p.GetPositionFromControl (c2), "C2");
\r
515 Assert.AreEqual (new TableLayoutPanelCellPosition (2, 0), p.GetPositionFromControl (c3), "C3");
\r
519 [Category ("NotWorking")]
\r
520 public void TestCellPositioning14 ()
\r
522 // Col span = 3, fixed grow style
\r
523 TableLayoutPanel p = new TableLayoutPanel ();
\r
524 p.GrowStyle = TableLayoutPanelGrowStyle.FixedSize;
\r
525 Control c1 = new Button ();
\r
530 p.SetColumnSpan (c1, 3);
\r
532 p.Controls.Add (c1);
\r
534 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
\r
538 public void TestCellPositioning15 ()
\r
540 // Column span = 2, but control is in the last column, forces control back into 1st column, next row
\r
541 // I have no clue why c3 shouldn't be in (1,0), but MS says it's not
\r
542 TableLayoutPanel p = new TableLayoutPanel ();
\r
543 Control c1 = new Button ();
\r
544 Control c2 = new Button ();
\r
545 Control c3 = new Button ();
\r
550 p.SetColumnSpan (c2, 2);
\r
551 p.SetCellPosition (c2, new TableLayoutPanelCellPosition (1, 0));
\r
553 p.Controls.Add (c1);
\r
554 p.Controls.Add (c2);
\r
555 p.Controls.Add (c3);
\r
557 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
\r
558 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c2), "C2");
\r
559 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 2), p.GetPositionFromControl (c3), "C3");
\r
563 public void TestCellPositioning16 ()
\r
565 // Row span = 2, but control is in the last row, creates new row
\r
566 TableLayoutPanel p = new TableLayoutPanel ();
\r
567 Control c1 = new Button ();
\r
568 Control c2 = new Button ();
\r
569 Control c3 = new Button ();
\r
574 p.SetRowSpan (c3, 2);
\r
575 p.SetCellPosition (c3, new TableLayoutPanelCellPosition (0, 1));
\r
577 p.Controls.Add (c1);
\r
578 p.Controls.Add (c2);
\r
579 p.Controls.Add (c3);
\r
581 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
\r
582 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 0), p.GetPositionFromControl (c2), "C2");
\r
583 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c3), "C3");
\r
587 public void TestRowColumnSizes1 ()
\r
589 // Row span = 2, but control is in the last row, creates new row
\r
590 TableLayoutPanel p = new TableLayoutPanel ();
\r
591 Control c1 = new Button ();
\r
592 Control c2 = new Button ();
\r
593 Control c3 = new Button ();
\r
598 p.RowStyles.Add (new RowStyle (SizeType.Percent, 100F));
\r
600 p.Controls.Add (c1);
\r
601 p.Controls.Add (c2);
\r
602 p.Controls.Add (c3);
\r
604 Assert.AreEqual (71, p.GetRowHeights ()[0], "D1");
\r
605 Assert.AreEqual (29, p.GetRowHeights ()[1], "D2");
\r
609 public void TestRowColumnSizes2 ()
\r
611 // Row span = 2, but control is in the last row, creates new row
\r
612 TableLayoutPanel p = new TableLayoutPanel ();
\r
613 Control c1 = new Button ();
\r
614 Control c2 = new Button ();
\r
615 Control c3 = new Button ();
\r
620 p.RowStyles.Add (new RowStyle (SizeType.Absolute, 100F));
\r
622 p.Controls.Add (c1);
\r
623 p.Controls.Add (c2);
\r
624 p.Controls.Add (c3);
\r
626 Assert.AreEqual (100, p.GetRowHeights ()[0], "D1");
\r
627 Assert.AreEqual (29, p.GetRowHeights ()[1], "D2");
\r
631 public void TestRowColumnSizes3 ()
\r
633 // Row span = 2, but control is in the last row, creates new row
\r
634 TableLayoutPanel p = new TableLayoutPanel ();
\r
635 Control c1 = new Button ();
\r
636 Control c2 = new Button ();
\r
637 Control c3 = new Button ();
\r
638 Control c4 = new Button ();
\r
639 Control c5 = new Button ();
\r
644 p.RowStyles.Add (new RowStyle (SizeType.Percent, 100F));
\r
646 p.Controls.Add (c1);
\r
647 p.Controls.Add (c2);
\r
648 p.Controls.Add (c3);
\r
649 p.Controls.Add (c4);
\r
650 p.Controls.Add (c5);
\r
652 Assert.AreEqual (42, p.GetRowHeights ()[0], "D1");
\r
653 Assert.AreEqual (29, p.GetRowHeights ()[1], "D2");
\r
654 Assert.AreEqual (29, p.GetRowHeights ()[2], "D3");
\r
658 public void TestRowColumnSizes4 ()
\r
660 // Row span = 2, but control is in the last row, creates new row
\r
661 TableLayoutPanel p = new TableLayoutPanel ();
\r
662 Control c1 = new Button ();
\r
663 Control c2 = new Button ();
\r
664 Control c3 = new Button ();
\r
665 Control c4 = new Button ();
\r
666 Control c5 = new Button ();
\r
667 Control c6 = new Button ();
\r
668 Control c7 = new Button ();
\r
673 p.RowStyles.Add (new RowStyle (SizeType.Percent, 100F));
\r
675 p.Controls.Add (c1);
\r
676 p.Controls.Add (c2);
\r
677 p.Controls.Add (c3);
\r
678 p.Controls.Add (c4);
\r
679 p.Controls.Add (c5);
\r
680 p.Controls.Add (c6);
\r
681 p.Controls.Add (c7);
\r
683 //Assert.AreEqual (100, p.GetRowHeights ()[0], "D1");
\r
684 Assert.AreEqual (29, p.GetRowHeights ()[1], "D2");
\r
685 Assert.AreEqual (29, p.GetRowHeights ()[2], "D3");
\r
686 Assert.AreEqual (29, p.GetRowHeights ()[3], "D4");
\r
690 public void TestRowColumnSizes5 ()
\r
692 // 2 Absolute Columns/Rows
\r
693 TableLayoutPanel p = new TableLayoutPanel ();
\r
694 Control c1 = new Button ();
\r
695 Control c2 = new Button ();
\r
696 Control c3 = new Button ();
\r
701 p.RowStyles.Add (new RowStyle (SizeType.Absolute, 20));
\r
702 p.RowStyles.Add (new RowStyle (SizeType.Absolute, 30));
\r
703 p.ColumnStyles.Add (new ColumnStyle (SizeType.Absolute, 20));
\r
704 p.ColumnStyles.Add (new ColumnStyle (SizeType.Absolute, 30));
\r
706 p.Controls.Add (c1);
\r
707 p.Controls.Add (c2);
\r
708 p.Controls.Add (c3);
\r
710 Assert.AreEqual (20, p.GetRowHeights ()[0], "D1");
\r
711 Assert.AreEqual (80, p.GetRowHeights ()[1], "D2");
\r
712 Assert.AreEqual (20, p.GetColumnWidths ()[0], "D3");
\r
713 Assert.AreEqual (180, p.GetColumnWidths ()[1], "D4");
\r
717 public void TestRowColumnSizes6 ()
\r
719 // 2 50% Columns/Rows
\r
720 TableLayoutPanel p = new TableLayoutPanel ();
\r
721 Control c1 = new Button ();
\r
722 Control c2 = new Button ();
\r
723 Control c3 = new Button ();
\r
728 p.RowStyles.Add (new RowStyle (SizeType.Percent, 50));
\r
729 p.RowStyles.Add (new RowStyle (SizeType.Percent, 50));
\r
730 p.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 50));
\r
731 p.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 50));
\r
733 p.Controls.Add (c1);
\r
734 p.Controls.Add (c2);
\r
735 p.Controls.Add (c3);
\r
737 Assert.AreEqual (50, p.GetRowHeights ()[0], "D1");
\r
738 Assert.AreEqual (50, p.GetRowHeights ()[1], "D2");
\r
739 Assert.AreEqual (100, p.GetColumnWidths ()[0], "D3");
\r
740 Assert.AreEqual (100, p.GetColumnWidths ()[1], "D4");
\r
744 public void TestRowColumnSizes7 ()
\r
746 // 1 Absolute and 2 Percent Columns/Rows
\r
747 TableLayoutPanel p = new TableLayoutPanel ();
\r
748 Control c1 = new Button ();
\r
749 Control c2 = new Button ();
\r
750 Control c3 = new Button ();
\r
755 p.RowStyles.Add (new RowStyle (SizeType.Absolute, 50));
\r
756 p.RowStyles.Add (new RowStyle (SizeType.Percent, 50));
\r
757 p.RowStyles.Add (new RowStyle (SizeType.Percent, 50));
\r
758 p.ColumnStyles.Add (new ColumnStyle (SizeType.Absolute, 50));
\r
759 p.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 50));
\r
760 p.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 50));
\r
762 p.Controls.Add (c1);
\r
763 p.Controls.Add (c2);
\r
764 p.Controls.Add (c3);
\r
766 Assert.AreEqual (50, p.GetRowHeights ()[0], "D1");
\r
767 Assert.AreEqual (25, p.GetRowHeights ()[1], "D2");
\r
768 Assert.AreEqual (25, p.GetRowHeights ()[2], "D3");
\r
769 Assert.AreEqual (50, p.GetColumnWidths ()[0], "D4");
\r
770 Assert.AreEqual (75, p.GetColumnWidths ()[1], "D5");
\r
771 Assert.AreEqual (75, p.GetColumnWidths ()[2], "D6");
\r
775 public void TestRowColumnSizes8 ()
\r
777 // 1 Absolute and 2 Percent Columns/Rows (with total percents > 100)
\r
778 TableLayoutPanel p = new TableLayoutPanel ();
\r
779 Control c1 = new Button ();
\r
780 Control c2 = new Button ();
\r
781 Control c3 = new Button ();
\r
786 p.RowStyles.Add (new RowStyle (SizeType.Absolute, 50));
\r
787 p.RowStyles.Add (new RowStyle (SizeType.Percent, 100));
\r
788 p.RowStyles.Add (new RowStyle (SizeType.Percent, 100));
\r
789 p.ColumnStyles.Add (new ColumnStyle (SizeType.Absolute, 50));
\r
790 p.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 100));
\r
791 p.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 100));
\r
793 p.Controls.Add (c1);
\r
794 p.Controls.Add (c2);
\r
795 p.Controls.Add (c3);
\r
797 Assert.AreEqual (50, p.GetRowHeights ()[0], "D1");
\r
798 Assert.AreEqual (25, p.GetRowHeights ()[1], "D2");
\r
799 Assert.AreEqual (25, p.GetRowHeights ()[2], "D3");
\r
800 Assert.AreEqual (50, p.GetColumnWidths ()[0], "D4");
\r
801 Assert.AreEqual (75, p.GetColumnWidths ()[1], "D5");
\r
802 Assert.AreEqual (75, p.GetColumnWidths ()[2], "D6");
\r
806 public void TestRowColumnSizes9 ()
\r
808 // 1 Absolute and 2 Percent Columns/Rows (with total percents > 100)
\r
809 TableLayoutPanel p = new TableLayoutPanel ();
\r
810 Control c1 = new Button ();
\r
811 Control c2 = new Button ();
\r
812 Control c3 = new Button ();
\r
817 p.RowStyles.Add (new RowStyle (SizeType.Absolute, 50));
\r
818 p.RowStyles.Add (new RowStyle (SizeType.Percent, 80));
\r
819 p.RowStyles.Add (new RowStyle (SizeType.Percent, 40));
\r
820 p.ColumnStyles.Add (new ColumnStyle (SizeType.Absolute, 50));
\r
821 p.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 80));
\r
822 p.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 40));
\r
824 p.Controls.Add (c1);
\r
825 p.Controls.Add (c2);
\r
826 p.Controls.Add (c3);
\r
828 Assert.AreEqual (50, p.GetRowHeights ()[0], "D1");
\r
829 Assert.AreEqual (33, p.GetRowHeights ()[1], "D2");
\r
830 Assert.AreEqual (17, p.GetRowHeights ()[2], "D3");
\r
831 Assert.AreEqual (50, p.GetColumnWidths ()[0], "D4");
\r
832 Assert.AreEqual (100, p.GetColumnWidths ()[1], "D5");
\r
833 Assert.AreEqual (50, p.GetColumnWidths ()[2], "D6");
\r
837 public void TestRowColumnSizes10 ()
\r
839 // 2 AutoSize Columns/Rows
\r
840 TableLayoutPanel p = new TableLayoutPanel ();
\r
841 Control c1 = new Button ();
\r
842 Control c2 = new Button ();
\r
843 Control c3 = new Button ();
\r
848 p.RowStyles.Add (new RowStyle (SizeType.AutoSize));
\r
849 p.RowStyles.Add (new RowStyle (SizeType.AutoSize));
\r
850 p.ColumnStyles.Add (new ColumnStyle (SizeType.AutoSize));
\r
851 p.ColumnStyles.Add (new ColumnStyle (SizeType.AutoSize));
\r
853 p.Controls.Add (c1);
\r
854 p.Controls.Add (c2);
\r
855 p.Controls.Add (c3);
\r
857 Assert.AreEqual (29, p.GetRowHeights ()[0], "D1");
\r
858 Assert.AreEqual (71, p.GetRowHeights ()[1], "D2");
\r
859 Assert.AreEqual (81, p.GetColumnWidths ()[0], "D3");
\r
860 Assert.AreEqual (119, p.GetColumnWidths ()[1], "D4");
\r
864 public void Bug81843 ()
\r
866 Form f = new Form ();
\r
867 f.ShowInTaskbar = false;
\r
869 TableLayoutPanel tableLayoutPanel1;
\r
874 tableLayoutPanel1 = new TableLayoutPanel ();
\r
875 button2 = new Button ();
\r
876 button4 = new Button ();
\r
877 textBox1 = new TextBox ();
\r
878 tableLayoutPanel1.SuspendLayout ();
\r
879 f.SuspendLayout ();
\r
881 tableLayoutPanel1.AutoSize = true;
\r
882 tableLayoutPanel1.ColumnCount = 3;
\r
883 tableLayoutPanel1.ColumnStyles.Add (new ColumnStyle ());
\r
884 tableLayoutPanel1.ColumnStyles.Add (new ColumnStyle ());
\r
885 tableLayoutPanel1.ColumnStyles.Add (new ColumnStyle ());
\r
886 tableLayoutPanel1.Controls.Add (button2, 0, 1);
\r
887 tableLayoutPanel1.Controls.Add (button4, 2, 1);
\r
888 tableLayoutPanel1.Controls.Add (textBox1, 1, 0);
\r
889 tableLayoutPanel1.Location = new Point (0, 0);
\r
890 tableLayoutPanel1.RowCount = 2;
\r
891 tableLayoutPanel1.RowStyles.Add (new RowStyle (SizeType.Percent, 50F));
\r
892 tableLayoutPanel1.RowStyles.Add (new RowStyle (SizeType.Percent, 50F));
\r
893 tableLayoutPanel1.Size = new Size (292, 287);
\r
895 button2.Size = new Size (75, 23);
\r
897 button4.Size = new Size (75, 23);
\r
899 textBox1.Dock = DockStyle.Fill;
\r
900 textBox1.Location = new Point (84, 3);
\r
901 textBox1.Multiline = true;
\r
902 textBox1.Size = new Size (94, 137);
\r
904 f.ClientSize = new Size (292, 312);
\r
905 f.Controls.Add (tableLayoutPanel1);
\r
908 tableLayoutPanel1.ResumeLayout (false);
\r
909 tableLayoutPanel1.PerformLayout ();
\r
910 f.ResumeLayout (false);
\r
911 f.PerformLayout ();
\r
915 Assert.AreEqual (new Rectangle (3, 146, 75, 23), button2.Bounds, "A1");
\r
916 Assert.AreEqual (new Rectangle (184, 146, 75, 23), button4.Bounds, "A2");
\r
917 Assert.AreEqual (new Rectangle (84, 3, 94, 137), textBox1.Bounds, "A3");
\r
922 [Test] // From bug #81884
\r
923 public void CellBorderStyle ()
\r
925 Form f = new Form ();
\r
926 f.ShowInTaskbar = false;
\r
928 TableLayoutPanel p = new TableLayoutPanel ();
\r
929 p = new TableLayoutPanel ();
\r
931 p.ColumnStyles.Add (new ColumnStyle ());
\r
932 p.ColumnStyles.Add (new ColumnStyle ());
\r
933 p.ColumnStyles.Add (new ColumnStyle ());
\r
934 p.Dock = DockStyle.Top;
\r
937 p.RowStyles.Add (new RowStyle (SizeType.Percent, 50F));
\r
938 p.RowStyles.Add (new RowStyle (SizeType.Percent, 50F));
\r
939 f.Controls.Add (p);
\r
941 Label _labelA = new Label ();
\r
942 _labelA.Dock = DockStyle.Fill;
\r
943 _labelA.Size = new Size (95, 20);
\r
944 _labelA.Text = "A";
\r
945 p.Controls.Add (_labelA, 0, 0);
\r
947 Label _labelB = new Label ();
\r
948 _labelB.Dock = DockStyle.Fill;
\r
949 _labelB.Size = new Size (95, 20);
\r
950 _labelB.Text = "B";
\r
951 p.Controls.Add (_labelB, 1, 0);
\r
953 Label _labelC = new Label ();
\r
954 _labelC.Dock = DockStyle.Fill;
\r
955 _labelC.Size = new Size (95, 20);
\r
956 _labelC.Text = "C";
\r
957 p.Controls.Add (_labelC, 2, 0);
\r
959 Label _labelD = new Label ();
\r
960 _labelD.Dock = DockStyle.Fill;
\r
961 _labelD.Size = new Size (95, 20);
\r
962 _labelD.Text = "D";
\r
963 p.Controls.Add (_labelD, 0, 1);
\r
965 Label _labelE = new Label ();
\r
966 _labelE.Dock = DockStyle.Fill;
\r
967 _labelE.Size = new Size (95, 20);
\r
968 _labelE.Text = "E";
\r
969 p.Controls.Add (_labelE, 1, 1);
\r
971 Label _labelF = new Label ();
\r
972 _labelF.Dock = DockStyle.Fill;
\r
973 _labelF.Size = new Size (95, 20);
\r
974 _labelF.Text = "F";
\r
975 p.Controls.Add (_labelF, 2, 1);
\r
977 _labelA.BackColor = Color.Red;
\r
978 _labelB.BackColor = Color.Orange;
\r
979 _labelC.BackColor = Color.Yellow;
\r
980 _labelD.BackColor = Color.Green;
\r
981 _labelE.BackColor = Color.Blue;
\r
982 _labelF.BackColor = Color.Purple;
\r
986 Assert.AreEqual (new Rectangle (3, 0, 95, 100), _labelA.Bounds, "A1");
\r
987 Assert.AreEqual (new Rectangle (104, 0, 95, 100), _labelB.Bounds, "A2");
\r
988 Assert.AreEqual (new Rectangle (205, 0, 95, 100), _labelC.Bounds, "A3");
\r
989 Assert.AreEqual (new Rectangle (3, 100, 95, 100), _labelD.Bounds, "A4");
\r
990 Assert.AreEqual (new Rectangle (104, 100, 95, 100), _labelE.Bounds, "A5");
\r
991 Assert.AreEqual (new Rectangle (205, 100, 95, 100), _labelF.Bounds, "A6");
\r
993 p.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single;
\r
994 Assert.AreEqual (new Rectangle (4, 1, 95, 98), _labelA.Bounds, "A7");
\r
995 Assert.AreEqual (new Rectangle (106, 1, 95, 98), _labelB.Bounds, "A8");
\r
996 Assert.AreEqual (new Rectangle (208, 1, 95, 98), _labelC.Bounds, "A9");
\r
997 Assert.AreEqual (new Rectangle (4, 100, 95, 99), _labelD.Bounds, "A10");
\r
998 Assert.AreEqual (new Rectangle (106, 100, 95, 99), _labelE.Bounds, "A11");
\r
999 Assert.AreEqual (new Rectangle (208, 100, 95, 99), _labelF.Bounds, "A12");
\r
1001 p.CellBorderStyle = TableLayoutPanelCellBorderStyle.Inset;
\r
1002 Assert.AreEqual (new Rectangle (5, 2, 95, 97), _labelA.Bounds, "A13");
\r
1003 Assert.AreEqual (new Rectangle (108, 2, 95, 97), _labelB.Bounds, "A14");
\r
1004 Assert.AreEqual (new Rectangle (211, 2, 95, 97), _labelC.Bounds, "A15");
\r
1005 Assert.AreEqual (new Rectangle (5, 101, 95, 97), _labelD.Bounds, "A16");
\r
1006 Assert.AreEqual (new Rectangle (108, 101, 95, 97), _labelE.Bounds, "A17");
\r
1007 Assert.AreEqual (new Rectangle (211, 101, 95, 97), _labelF.Bounds, "A18");
\r
1009 p.CellBorderStyle = TableLayoutPanelCellBorderStyle.InsetDouble;
\r
1010 Assert.AreEqual (new Rectangle (6, 3, 95, 95), _labelA.Bounds, "A19");
\r
1011 Assert.AreEqual (new Rectangle (110, 3, 95, 95), _labelB.Bounds, "A20");
\r
1012 Assert.AreEqual (new Rectangle (214, 3, 95, 95), _labelC.Bounds, "A21");
\r
1013 Assert.AreEqual (new Rectangle (6, 101, 95, 96), _labelD.Bounds, "A22");
\r
1014 Assert.AreEqual (new Rectangle (110, 101, 95, 96), _labelE.Bounds, "A23");
\r
1015 Assert.AreEqual (new Rectangle (214, 101, 95, 96), _labelF.Bounds, "A24");
\r
1017 p.CellBorderStyle = TableLayoutPanelCellBorderStyle.Outset;
\r
1018 Assert.AreEqual (new Rectangle (5, 2, 95, 97), _labelA.Bounds, "A25");
\r
1019 Assert.AreEqual (new Rectangle (108, 2, 95, 97), _labelB.Bounds, "A26");
\r
1020 Assert.AreEqual (new Rectangle (211, 2, 95, 97), _labelC.Bounds, "A27");
\r
1021 Assert.AreEqual (new Rectangle (5, 101, 95, 97), _labelD.Bounds, "A28");
\r
1022 Assert.AreEqual (new Rectangle (108, 101, 95, 97), _labelE.Bounds, "A29");
\r
1023 Assert.AreEqual (new Rectangle (211, 101, 95, 97), _labelF.Bounds, "A30");
\r
1025 p.CellBorderStyle = TableLayoutPanelCellBorderStyle.OutsetDouble;
\r
1026 Assert.AreEqual (new Rectangle (6, 3, 95, 95), _labelA.Bounds, "A31");
\r
1027 Assert.AreEqual (new Rectangle (110, 3, 95, 95), _labelB.Bounds, "A32");
\r
1028 Assert.AreEqual (new Rectangle (214, 3, 95, 95), _labelC.Bounds, "A33");
\r
1029 Assert.AreEqual (new Rectangle (6, 101, 95, 96), _labelD.Bounds, "A34");
\r
1030 Assert.AreEqual (new Rectangle (110, 101, 95, 96), _labelE.Bounds, "A35");
\r
1031 Assert.AreEqual (new Rectangle (214, 101, 95, 96), _labelF.Bounds, "A36");
\r
1033 p.CellBorderStyle = TableLayoutPanelCellBorderStyle.OutsetPartial;
\r
1034 Assert.AreEqual (new Rectangle (6, 3, 95, 95), _labelA.Bounds, "A37");
\r
1035 Assert.AreEqual (new Rectangle (110, 3, 95, 95), _labelB.Bounds, "A38");
\r
1036 Assert.AreEqual (new Rectangle (214, 3, 95, 95), _labelC.Bounds, "A39");
\r
1037 Assert.AreEqual (new Rectangle (6, 101, 95, 96), _labelD.Bounds, "A40");
\r
1038 Assert.AreEqual (new Rectangle (110, 101, 95, 96), _labelE.Bounds, "A41");
\r
1039 Assert.AreEqual (new Rectangle (214, 101, 95, 96), _labelF.Bounds, "A42");
\r
1045 public void Bug81936 ()
\r
1047 Form f = new Form ();
\r
1048 f.ShowInTaskbar = false;
\r
1050 TableLayoutPanel tableLayoutPanel1;
\r
1054 tableLayoutPanel1 = new TableLayoutPanel ();
\r
1055 button2 = new Label ();
\r
1056 button4 = new Label ();
\r
1057 button2.Text = "Test1";
\r
1058 button4.Text = "Test2";
\r
1059 button2.Anchor = AnchorStyles.Left;
\r
1060 button4.Anchor = AnchorStyles.Left;
\r
1061 button2.Height = 14;
\r
1062 button4.Height = 14;
\r
1063 tableLayoutPanel1.SuspendLayout ();
\r
1064 f.SuspendLayout ();
\r
1066 tableLayoutPanel1.ColumnCount = 1;
\r
1067 tableLayoutPanel1.ColumnStyles.Add (new ColumnStyle ());
\r
1068 tableLayoutPanel1.Controls.Add (button2, 0, 0);
\r
1069 tableLayoutPanel1.Controls.Add (button4, 0, 1);
\r
1070 tableLayoutPanel1.Location = new Point (0, 0);
\r
1071 tableLayoutPanel1.RowCount = 2;
\r
1072 tableLayoutPanel1.RowStyles.Add (new RowStyle (SizeType.Absolute, 28F));
\r
1073 tableLayoutPanel1.RowStyles.Add (new RowStyle (SizeType.Absolute, 28F));
\r
1074 tableLayoutPanel1.Size = new Size (292, 56);
\r
1076 f.ClientSize = new Size (292, 312);
\r
1077 f.Controls.Add (tableLayoutPanel1);
\r
1080 tableLayoutPanel1.ResumeLayout (false);
\r
1081 tableLayoutPanel1.PerformLayout ();
\r
1082 f.ResumeLayout (false);
\r
1083 f.PerformLayout ();
\r
1087 Assert.AreEqual (new Rectangle (3, 7, 100, 14), button2.Bounds, "A1");
\r
1088 Assert.AreEqual (new Rectangle (3, 35, 100, 14), button4.Bounds, "A2");
\r
1094 public void Bug82605 ()
\r
1096 Form f = new Form ();
\r
1097 f.ShowInTaskbar = false;
\r
1099 Label l = new Label ();
\r
1101 TableLayoutPanel table = new TableLayoutPanel ();
\r
1102 table.ColumnCount = 1;
\r
1103 table.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 100F));
\r
1105 table.RowCount = 2;
\r
1106 table.RowStyles.Add (new RowStyle (SizeType.Percent, 100F));
\r
1107 table.RowStyles.Add (new RowStyle (SizeType.Absolute, 20F));
\r
1109 table.Controls.Add (l, 0, 1);
\r
1110 table.Location = new Point (0, 0);
\r
1111 table.Width = 250;
\r
1113 l.Anchor = AnchorStyles.Left | AnchorStyles.Right;
\r
1114 l.AutoSize = true;
\r
1115 l.Location = new Point (3, 352);
\r
1116 l.Size = new Size (578, 13);
\r
1117 l.Text = "label1";
\r
1118 l.TextAlign = ContentAlignment.MiddleCenter;
\r
1120 f.Controls.Add (table);
\r
1123 // Height is font dependent, but this bug is about the width anyways
\r
1124 Assert.AreEqual (244, l.Width, "A1");
\r
1127 [Test] // bug #82040
\r
1128 public void ShowNoChildren ()
\r
1130 Form form = new Form ();
\r
1131 form.ShowInTaskbar = false;
\r
1133 TableLayoutPanel tableLayoutPanel = new TableLayoutPanel ();
\r
1134 tableLayoutPanel.ColumnCount = 3;
\r
1135 tableLayoutPanel.Dock = DockStyle.Fill;
\r
1136 tableLayoutPanel.RowCount = 11;
\r
1137 form.Controls.Add (tableLayoutPanel);
\r
1144 [Test] // bug #82041
\r
1145 public void DontCallResumeLayout ()
\r
1147 Form form = new Form ();
\r
1148 form.ShowInTaskbar = false;
\r
1150 TableLayoutPanel tableLayoutPanel = new TableLayoutPanel ();
\r
1151 form.Controls.Add (tableLayoutPanel);
\r
1152 tableLayoutPanel.SuspendLayout ();
\r
1153 tableLayoutPanel.ColumnCount = 3;
\r
1154 tableLayoutPanel.Dock = DockStyle.Fill;
\r
1155 tableLayoutPanel.RowCount = 11;
\r
1156 tableLayoutPanel.Controls.Add (new Button ());
\r
1163 [Test] // bug #346246
\r
1164 public void AutoSizePanelVerical ()
\r
1166 Form f = new Form ();
\r
1167 f.ShowInTaskbar = false;
\r
1169 TableLayoutPanel tlp = new TableLayoutPanel ();
\r
1170 tlp.AutoSize = true;
\r
1171 tlp.AutoSizeMode = AutoSizeMode.GrowAndShrink;
\r
1172 tlp.ColumnCount = 1;
\r
1173 tlp.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 100F));
\r
1174 tlp.Location = new Point (12, 12);
\r
1175 tlp.Name = "tableLayoutPanel1";
\r
1177 tlp.RowStyles.Add (new RowStyle (SizeType.Percent, 50F));
\r
1178 tlp.RowStyles.Add (new RowStyle (SizeType.Percent, 50F));
\r
1179 tlp.Size = new Size (139, 182);
\r
1182 f.Controls.Add (tlp);
\r
1184 Button b = new Button ();
\r
1185 b.Size = new Size (100, 100);
\r
1186 tlp.Controls.Add (b, 0, 0);
\r
1188 PictureBox p = new PictureBox ();
\r
1189 p.Size = new Size (100, 100);
\r
1190 tlp.Controls.Add (p,0,1);
\r
1194 Assert.AreEqual (new Rectangle (12, 12, 106, 212), tlp.Bounds, "A1");
\r
1195 Assert.AreEqual (new Rectangle (3, 3, 100, 100), b.Bounds, "A2");
\r
1196 Assert.AreEqual (new Rectangle (3, 109, 100, 100), p.Bounds, "A3");
\r
1201 Assert.AreEqual (new Rectangle (12, 12, 126, 252), tlp.Bounds, "B1");
\r
1202 Assert.AreEqual (new Rectangle (3, 3, 120, 120), b.Bounds, "B2");
\r
1203 Assert.AreEqual (new Rectangle (3, 129, 100, 100), p.Bounds, "B3");
\r
1208 Assert.AreEqual (new Rectangle (12, 12, 126, 252), tlp.Bounds, "C1");
\r
1209 Assert.AreEqual (new Rectangle (3, 3, 120, 120), b.Bounds, "C2");
\r
1210 Assert.AreEqual (new Rectangle (3, 129, 120, 120), p.Bounds, "C3");
\r
1215 [Test] // bug #346246
\r
1216 public void AutoSizePanelHorizontal ()
\r
1218 Form f = new Form ();
\r
1219 f.ShowInTaskbar = false;
\r
1221 TableLayoutPanel tlp = new TableLayoutPanel ();
\r
1222 tlp.AutoSize = true;
\r
1223 tlp.AutoSizeMode = AutoSizeMode.GrowAndShrink;
\r
1224 tlp.ColumnCount = 2;
\r
1225 tlp.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 50F));
\r
1226 tlp.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 50F));
\r
1227 tlp.Location = new Point (12, 12);
\r
1228 tlp.Name = "tableLayoutPanel1";
\r
1230 tlp.RowStyles.Add (new RowStyle (SizeType.Percent, 100F));
\r
1231 tlp.Size = new Size (139, 182);
\r
1234 f.Controls.Add (tlp);
\r
1236 Button b = new Button ();
\r
1237 b.Size = new Size (100, 100);
\r
1238 tlp.Controls.Add (b, 0, 0);
\r
1240 PictureBox p = new PictureBox ();
\r
1241 p.Size = new Size (100, 100);
\r
1242 tlp.Controls.Add (p, 1, 0);
\r
1246 Assert.AreEqual (new Rectangle (12, 12, 212, 106), tlp.Bounds, "A1");
\r
1247 Assert.AreEqual (new Rectangle (3, 3, 100, 100), b.Bounds, "A2");
\r
1248 Assert.AreEqual (new Rectangle (109, 3, 100, 100), p.Bounds, "A3");
\r
1253 Assert.AreEqual (new Rectangle (12, 12, 252, 126), tlp.Bounds, "B1");
\r
1254 Assert.AreEqual (new Rectangle (3, 3, 120, 120), b.Bounds, "B2");
\r
1255 Assert.AreEqual (new Rectangle (129, 3, 100, 100), p.Bounds, "B3");
\r
1260 Assert.AreEqual (new Rectangle (12, 12, 252, 126), tlp.Bounds, "C1");
\r
1261 Assert.AreEqual (new Rectangle (3, 3, 120, 120), b.Bounds, "C2");
\r
1262 Assert.AreEqual (new Rectangle (129, 3, 120, 120), p.Bounds, "C3");
\r
1268 public void Bug354676 ()
\r
1270 Form f = new Form ();
\r
1272 TableLayoutPanel tlp = new TableLayoutPanel ();
\r
1273 tlp.Dock = DockStyle.Fill;
\r
1274 tlp.Padding = new Padding (40);
\r
1276 tlp.ColumnCount = 1;
\r
1277 f.Controls.Add (tlp);
\r
1279 Button b1 = new Button ();
\r
1280 tlp.Controls.Add (b1);
\r
1282 Button b2 = new Button ();
\r
1283 tlp.Controls.Add (b2);
\r
1287 Assert.AreEqual (new Rectangle (43, 43, 75, 23), b1.Bounds, "A1");
\r
1288 Assert.AreEqual (new Rectangle (43, 72, 75, 23), b2.Bounds, "A2");
\r
1295 public void Bug355408 ()
\r
1297 Form f = new Form ();
\r
1298 f.ClientSize = new Size (300, 300);
\r
1300 TableLayoutPanel tlp = new TableLayoutPanel ();
\r
1301 tlp.Dock = DockStyle.Fill;
\r
1303 tlp.ColumnCount = 2;
\r
1304 f.Controls.Add (tlp);
\r
1306 Button b1 = new Button ();
\r
1307 tlp.Controls.Add (b1);
\r
1309 Button b2 = new Button ();
\r
1310 tlp.Controls.Add (b2);
\r
1312 Button b3 = new Button ();
\r
1313 b3.Dock = DockStyle.Fill;
\r
1315 tlp.SetColumnSpan (b3, 2);
\r
1316 tlp.Controls.Add (b3);
\r
1320 Assert.AreEqual (new Rectangle (3, 3, 75, 23), b1.Bounds, "A1");
\r
1321 Assert.AreEqual (new Rectangle (84, 3, 75, 23), b2.Bounds, "A2");
\r
1322 Assert.AreEqual (new Rectangle (3, 32, 294, 265), b3.Bounds, "A3");
\r
1329 public void Bug354672 ()
\r
1331 Form f = new Form ();
\r
1332 f.ClientSize = new Size (300, 300);
\r
1334 TableLayoutPanel tlp = new TableLayoutPanel ();
\r
1335 tlp.AutoSize = true;
\r
1336 tlp.ColumnCount = 2;
\r
1338 f.Controls.Add (tlp);
\r
1340 TextBox t1 = new TextBox ();
\r
1341 t1.Dock = DockStyle.Fill;
\r
1342 tlp.Controls.Add (t1);
\r
1344 TextBox t2 = new TextBox ();
\r
1345 t2.Dock = DockStyle.Fill;
\r
1346 tlp.Controls.Add (t2);
\r
1348 Assert.AreEqual (new Size (212, t1.Height + 6), tlp.PreferredSize, "A1");
\r
1354 public void Bug354672More ()
\r
1356 Form f = new Form ();
\r
1357 f.ClientSize = new Size (300, 300);
\r
1359 TableLayoutPanel tlp = new TableLayoutPanel ();
\r
1360 tlp.AutoSize = true;
\r
1361 tlp.ColumnCount = 2;
\r
1363 tlp.ColumnStyles.Add (new ColumnStyle (SizeType.AutoSize));
\r
1364 tlp.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 50f));
\r
1366 f.Controls.Add (tlp);
\r
1368 TextBox t1 = new TextBox ();
\r
1369 t1.Dock = DockStyle.Fill;
\r
1370 tlp.Controls.Add (t1);
\r
1372 TextBox t2 = new TextBox ();
\r
1373 t2.Dock = DockStyle.Fill;
\r
1374 tlp.Controls.Add (t2);
\r
1376 Assert.AreEqual (new Size (212, t1.Height + 6), tlp.PreferredSize, "A1");
\r
1382 public void Bug367249 ()
\r
1384 // Setting a colspan greater than the number of columns was
\r
1385 // causing an IOORE, this test just should not exception
\r
1386 TableLayoutPanel LayoutPanel = new TableLayoutPanel ();
\r
1387 LayoutPanel.ColumnCount = 1;
\r
1388 LayoutPanel.RowCount = 2;
\r
1390 Button OkButton = new Button ();
\r
1391 OkButton.Text = "OK";
\r
1392 LayoutPanel.Controls.Add (OkButton);
\r
1393 LayoutPanel.SetColumnSpan (OkButton, 3);
\r
1397 public void Bug396141 ()
\r
1399 // The issue is the user has set the RowCount to 0, but after
\r
1400 // we arrange the controls, we have 1 row. GetPreferredSize (for
\r
1401 // AutoSize) was using 0 instead of 1.
\r
1403 Form f = new Form ();
\r
1404 f.ClientSize = new Size (300, 300);
\r
1405 f.ShowInTaskbar = false;
\r
1407 TableLayoutPanel tlp = new TableLayoutPanel ();
\r
1408 tlp.AutoSize = true;
\r
1409 tlp.AutoSizeMode = AutoSizeMode.GrowAndShrink;
\r
1410 tlp.ColumnCount = 2;
\r
1413 f.Controls.Add (tlp);
\r
1415 TextBox t1 = new TextBox ();
\r
1416 t1.Dock = DockStyle.Fill;
\r
1417 tlp.Controls.Add (t1);
\r
1419 TextBox t2 = new TextBox ();
\r
1420 t2.Dock = DockStyle.Fill;
\r
1421 tlp.Controls.Add (t2);
\r
1425 Assert.IsTrue (tlp.Height > 0, "Height must be > 0");
\r
1426 Assert.IsTrue (tlp.Width > 0, "Width must be > 0");
\r
1432 public void Bug396433 ()
\r
1434 // We were not taking the CellBorderStyle into account when calculating
\r
1435 // the preferred size.
\r
1436 Form f = new Form ();
\r
1437 f.ClientSize = new Size (300, 300);
\r
1438 f.ShowInTaskbar = false;
\r
1440 TableLayoutPanel tlp = new TableLayoutPanel ();
\r
1441 tlp.AutoSize = true;
\r
1442 tlp.AutoSizeMode = AutoSizeMode.GrowAndShrink;
\r
1443 tlp.ColumnCount = 2;
\r
1446 f.Controls.Add (tlp);
\r
1448 Button t1 = new Button ();
\r
1449 tlp.Controls.Add (t1);
\r
1451 Button t2 = new Button ();
\r
1452 tlp.Controls.Add (t2);
\r
1456 Assert.AreEqual (new Size (162, 29), tlp.PreferredSize, "A1");
\r
1458 tlp.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single;
\r
1460 Assert.AreEqual (new Size (165, 31), tlp.PreferredSize, "A2");
\r
1466 public void IgnoreAutoSizeMode ()
\r
1468 // It would seem that AutoSizeMode for a TableLayoutPanel is always
\r
1469 // treated as GrowAndShrink
\r
1470 Form f = new Form ();
\r
1471 f.ClientSize = new Size (300, 300);
\r
1472 f.ShowInTaskbar = false;
\r
1474 TableLayoutPanel tlp = new TableLayoutPanel ();
\r
1475 tlp.AutoSize = true;
\r
1476 tlp.Dock = DockStyle.Top;
\r
1477 tlp.ColumnCount = 1;
\r
1480 f.Controls.Add (tlp);
\r
1482 Button t1 = new Button ();
\r
1483 tlp.Controls.Add (t1);
\r
1487 Assert.AreEqual (29, tlp.Height, "A1");
\r
1489 tlp.AutoSizeMode = AutoSizeMode.GrowAndShrink;
\r
1491 Assert.AreEqual (29, tlp.Height, "A2");
\r