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
30 using System.Drawing;
\r
32 using System.Runtime.Serialization.Formatters.Binary;
\r
33 using System.Windows.Forms;
\r
34 using NUnit.Framework;
\r
36 namespace MonoTests.System.Windows.Forms
\r
39 public class TableLayoutTests : TestHelper
\r
42 public void TestConstruction ()
\r
44 TableLayoutPanel p = new TableLayoutPanel ();
\r
46 Assert.AreEqual (BorderStyle.None, p.BorderStyle, "A1");
\r
47 Assert.AreEqual (TableLayoutPanelCellBorderStyle.None, p.CellBorderStyle, "A2");
\r
48 Assert.AreEqual (0, p.ColumnCount, "A3");
\r
49 Assert.AreEqual (TableLayoutPanelGrowStyle.AddRows, p.GrowStyle, "A4");
\r
50 Assert.AreEqual ("System.Windows.Forms.Layout.TableLayout", p.LayoutEngine.ToString (), "A5");
\r
51 Assert.AreEqual ("System.Windows.Forms.TableLayoutSettings", p.LayoutSettings.ToString (), "A6");
\r
52 Assert.AreEqual (0, p.RowCount, "A7");
\r
53 Assert.AreEqual (0, p.ColumnStyles.Count, "A8");
\r
54 Assert.AreEqual (0, p.RowStyles.Count, "A9");
\r
55 Assert.AreEqual (new Size (200, 100), p.Size, "A10");
\r
59 public void TestPropertySetters ()
\r
61 TableLayoutPanel p = new TableLayoutPanel ();
\r
63 p.BorderStyle = BorderStyle.Fixed3D;
\r
64 p.CellBorderStyle = TableLayoutPanelCellBorderStyle.OutsetDouble;
\r
66 p.GrowStyle = TableLayoutPanelGrowStyle.FixedSize;
\r
69 Assert.AreEqual (BorderStyle.Fixed3D, p.BorderStyle, "A1");
\r
70 Assert.AreEqual (TableLayoutPanelCellBorderStyle.OutsetDouble, p.CellBorderStyle, "A2");
\r
71 Assert.AreEqual (1, p.ColumnCount, "A3");
\r
72 Assert.AreEqual (TableLayoutPanelGrowStyle.FixedSize, p.GrowStyle, "A4");
\r
73 Assert.AreEqual (1, p.RowCount, "A7");
\r
77 public void TestExtenderMethods ()
\r
79 TableLayoutPanel p = new TableLayoutPanel ();
\r
80 Control c = new Button ();
\r
82 Assert.AreEqual (new TableLayoutPanelCellPosition (-1, -1), p.GetCellPosition (c), "A1");
\r
83 Assert.AreEqual (-1, p.GetColumn (c), "A2");
\r
84 Assert.AreEqual (1, p.GetColumnSpan (c), "A3");
\r
85 Assert.AreEqual (-1, p.GetRow (c), "A4");
\r
86 Assert.AreEqual (1, p.GetRowSpan (c), "A5");
\r
88 p.SetCellPosition (c, new TableLayoutPanelCellPosition (1, 1));
\r
89 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 1), p.GetCellPosition (c), "A6");
\r
92 Assert.AreEqual (2, p.GetColumn (c), "A7");
\r
94 Assert.AreEqual (2, p.GetRow (c), "A9");
\r
96 p.SetColumnSpan (c, 2);
\r
97 Assert.AreEqual (2, p.GetColumnSpan (c), "A8");
\r
100 p.SetRowSpan (c, 2);
\r
101 Assert.AreEqual (2, p.GetRowSpan (c), "A10");
\r
103 Assert.AreEqual (new TableLayoutPanelCellPosition (2, 2), p.GetCellPosition (c), "A11");
\r
106 //Assert.AreEqual (new TableLayoutPanelCellPosition (-1, -1), p.GetPositionFromControl (c), "A12");
\r
107 //Assert.AreEqual (c, p.GetControlFromPosition(0, 0), "A13");
\r
111 public void TestColumnStyles ()
\r
113 TableLayoutPanel p = new TableLayoutPanel ();
\r
115 p.ColumnStyles.Add (new ColumnStyle ());
\r
116 p.ColumnStyles.Add (new ColumnStyle (SizeType.Absolute));
\r
117 p.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 20F));
\r
119 Assert.AreEqual (3, p.ColumnStyles.Count, "A1");
\r
120 Assert.AreEqual (SizeType.AutoSize, p.ColumnStyles[0].SizeType, "A2");
\r
121 Assert.AreEqual (0, p.ColumnStyles[0].Width, "A3");
\r
122 Assert.AreEqual (SizeType.Absolute, p.ColumnStyles[1].SizeType, "A4");
\r
123 Assert.AreEqual (0, p.ColumnStyles[1].Width, "A5");
\r
124 Assert.AreEqual (SizeType.Percent, p.ColumnStyles[2].SizeType, "A6");
\r
125 Assert.AreEqual (20F, p.ColumnStyles[2].Width, "A7");
\r
127 p.ColumnStyles.Remove (p.ColumnStyles[0]);
\r
129 Assert.AreEqual (2, p.ColumnStyles.Count, "A8");
\r
130 Assert.AreEqual (SizeType.Absolute, p.ColumnStyles[0].SizeType, "A9");
\r
131 Assert.AreEqual (0, p.ColumnStyles[0].Width, "A10");
\r
132 Assert.AreEqual (SizeType.Percent, p.ColumnStyles[1].SizeType, "A11");
\r
133 Assert.AreEqual (20F, p.ColumnStyles[1].Width, "A12");
\r
137 public void TestRowStyles ()
\r
139 TableLayoutPanel p = new TableLayoutPanel ();
\r
141 p.RowStyles.Add (new RowStyle ());
\r
142 p.RowStyles.Add (new RowStyle (SizeType.Absolute));
\r
143 p.RowStyles.Add (new RowStyle (SizeType.Percent, 20F));
\r
145 Assert.AreEqual (3, p.RowStyles.Count, "A1");
\r
146 Assert.AreEqual (SizeType.AutoSize, p.RowStyles[0].SizeType, "A2");
\r
147 Assert.AreEqual (0, p.RowStyles[0].Height, "A3");
\r
148 Assert.AreEqual (SizeType.Absolute, p.RowStyles[1].SizeType, "A4");
\r
149 Assert.AreEqual (0, p.RowStyles[1].Height, "A5");
\r
150 Assert.AreEqual (SizeType.Percent, p.RowStyles[2].SizeType, "A6");
\r
151 Assert.AreEqual (20F, p.RowStyles[2].Height, "A7");
\r
153 p.RowStyles.Remove (p.RowStyles[0]);
\r
155 Assert.AreEqual (2, p.RowStyles.Count, "A8");
\r
156 Assert.AreEqual (SizeType.Absolute, p.RowStyles[0].SizeType, "A9");
\r
157 Assert.AreEqual (0, p.RowStyles[0].Height, "A10");
\r
158 Assert.AreEqual (SizeType.Percent, p.RowStyles[1].SizeType, "A11");
\r
159 Assert.AreEqual (20F, p.RowStyles[1].Height, "A12");
\r
163 public void TestColumnStyles3 ()
\r
165 // Don't lose the 2nd style
\r
166 TableLayoutPanel p = new TableLayoutPanel ();
\r
169 p.ColumnStyles.Add (new ColumnStyle (SizeType.Absolute, 20F));
\r
170 p.ColumnStyles.Add (new ColumnStyle (SizeType.Absolute, 20F));
\r
174 Assert.AreEqual (2, p.ColumnStyles.Count, "A1");
\r
178 public void TestColumnStyles2 ()
\r
180 // Don't lose the 2nd style
\r
181 TableLayoutPanel p = new TableLayoutPanel ();
\r
184 p.ColumnStyles.Add (new ColumnStyle (SizeType.Absolute, 20F));
\r
188 Assert.AreEqual (1, p.ColumnStyles.Count, "A2");
\r
192 public void TestCellPositioning ()
\r
195 TableLayoutPanel p = new TableLayoutPanel ();
\r
196 Control c1 = new Button ();
\r
197 Control c2 = new Button ();
\r
198 Control c3 = new Button ();
\r
199 Control c4 = new Button ();
\r
204 p.Controls.Add (c1);
\r
205 p.Controls.Add (c2);
\r
206 p.Controls.Add (c3);
\r
207 p.Controls.Add (c4);
\r
209 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
\r
210 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 0), p.GetPositionFromControl (c2), "C2");
\r
211 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c3), "C3");
\r
212 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 1), p.GetPositionFromControl (c4), "C4");
\r
216 public void TestCellPositioning2 ()
\r
218 // Growstyle = Add Rows
\r
219 TableLayoutPanel p = new TableLayoutPanel ();
\r
220 Control c1 = new Button ();
\r
221 Control c2 = new Button ();
\r
222 Control c3 = new Button ();
\r
223 Control c4 = new Button ();
\r
224 Control c5 = new Button ();
\r
225 Control c6 = new Button ();
\r
230 p.Controls.Add (c1);
\r
231 p.Controls.Add (c2);
\r
232 p.Controls.Add (c3);
\r
233 p.Controls.Add (c4);
\r
234 p.Controls.Add (c5);
\r
235 p.Controls.Add (c6);
\r
237 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
\r
238 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 0), p.GetPositionFromControl (c2), "C2");
\r
239 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c3), "C3");
\r
240 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 1), p.GetPositionFromControl (c4), "C4");
\r
241 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 2), p.GetPositionFromControl (c5), "C5");
\r
242 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 2), p.GetPositionFromControl (c6), "C6");
\r
246 public void TestCellPositioning3 ()
\r
248 // Growstyle = Add Columns
\r
249 TableLayoutPanel p = new TableLayoutPanel ();
\r
250 p.GrowStyle = TableLayoutPanelGrowStyle.AddColumns;
\r
252 Control c1 = new Button ();
\r
253 Control c2 = new Button ();
\r
254 Control c3 = new Button ();
\r
255 Control c4 = new Button ();
\r
256 Control c5 = new Button ();
\r
257 Control c6 = new Button ();
\r
262 p.Controls.Add (c1);
\r
263 p.Controls.Add (c2);
\r
264 p.Controls.Add (c3);
\r
265 p.Controls.Add (c4);
\r
266 p.Controls.Add (c5);
\r
267 p.Controls.Add (c6);
\r
269 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
\r
270 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 0), p.GetPositionFromControl (c2), "C2");
\r
271 Assert.AreEqual (new TableLayoutPanelCellPosition (2, 0), p.GetPositionFromControl (c3), "C3");
\r
272 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c4), "C4");
\r
273 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 1), p.GetPositionFromControl (c5), "C5");
\r
274 Assert.AreEqual (new TableLayoutPanelCellPosition (2, 1), p.GetPositionFromControl (c6), "C6");
\r
278 [ExpectedException (typeof (ArgumentException))]
\r
279 public void TestCellPositioning4 ()
\r
281 // Growstyle = Fixed Size
\r
282 TableLayoutPanel p = new TableLayoutPanel ();
\r
283 p.GrowStyle = TableLayoutPanelGrowStyle.FixedSize;
\r
285 Control c1 = new Button ();
\r
286 Control c2 = new Button ();
\r
287 Control c3 = new Button ();
\r
288 Control c4 = new Button ();
\r
289 Control c5 = new Button ();
\r
294 p.Controls.Add (c1);
\r
295 p.Controls.Add (c2);
\r
296 p.Controls.Add (c3);
\r
297 p.Controls.Add (c4);
\r
298 p.Controls.Add (c5);
\r
302 public void TestCellPositioning5 ()
\r
304 // One control have fixed position
\r
305 TableLayoutPanel p = new TableLayoutPanel ();
\r
306 Control c1 = new Button ();
\r
307 Control c2 = new Button ();
\r
308 Control c3 = new Button ();
\r
309 Control c4 = new Button ();
\r
314 p.SetCellPosition (c4, new TableLayoutPanelCellPosition (0, 0));
\r
316 p.Controls.Add (c1);
\r
317 p.Controls.Add (c2);
\r
318 p.Controls.Add (c3);
\r
319 p.Controls.Add (c4);
\r
321 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c4), "C1");
\r
322 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 0), p.GetPositionFromControl (c1), "C2");
\r
323 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c2), "C3");
\r
324 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 1), p.GetPositionFromControl (c3), "C4");
\r
328 public void TestCellPositioning6 ()
\r
330 // One control has fixed column, it should be ignored
\r
331 TableLayoutPanel p = new TableLayoutPanel ();
\r
332 Control c1 = new Button ();
\r
333 Control c2 = new Button ();
\r
334 Control c3 = new Button ();
\r
335 Control c4 = new Button ();
\r
340 p.SetColumn (c3, 1);
\r
342 p.Controls.Add (c1);
\r
343 p.Controls.Add (c2);
\r
344 p.Controls.Add (c3);
\r
345 p.Controls.Add (c4);
\r
347 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
\r
348 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 0), p.GetPositionFromControl (c2), "C2");
\r
349 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c3), "C3");
\r
350 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 1), p.GetPositionFromControl (c4), "C4");
\r
354 public void TestCellPositioning7 ()
\r
356 // One control has fixed column and row
\r
357 TableLayoutPanel p = new TableLayoutPanel ();
\r
358 Control c1 = new Button ();
\r
359 Control c2 = new Button ();
\r
360 Control c3 = new Button ();
\r
361 Control c4 = new Button ();
\r
366 p.SetColumn (c3, 1);
\r
369 p.Controls.Add (c1);
\r
370 p.Controls.Add (c2);
\r
371 p.Controls.Add (c3);
\r
372 p.Controls.Add (c4);
\r
374 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
\r
375 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 0), p.GetPositionFromControl (c2), "C2");
\r
376 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 1), p.GetPositionFromControl (c3), "C3");
\r
377 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c4), "C4");
\r
381 public void TestCellPositioning8 ()
\r
384 TableLayoutPanel p = new TableLayoutPanel ();
\r
385 Control c1 = new Button ();
\r
386 Control c2 = new Button ();
\r
387 Control c3 = new Button ();
\r
392 p.SetColumnSpan (c1, 2);
\r
394 p.Controls.Add (c1);
\r
395 p.Controls.Add (c2);
\r
396 p.Controls.Add (c3);
\r
398 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
\r
399 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c2), "C2");
\r
400 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 1), p.GetPositionFromControl (c3), "C3");
\r
404 public void TestCellPositioning9 ()
\r
407 TableLayoutPanel p = new TableLayoutPanel ();
\r
408 Control c1 = new Button ();
\r
409 Control c2 = new Button ();
\r
410 Control c3 = new Button ();
\r
415 p.SetRowSpan (c1, 2);
\r
417 p.Controls.Add (c1);
\r
418 p.Controls.Add (c2);
\r
419 p.Controls.Add (c3);
\r
421 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
\r
422 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 0), p.GetPositionFromControl (c2), "C2");
\r
423 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 1), p.GetPositionFromControl (c3), "C3");
\r
427 public void TestCellPositioning10 ()
\r
429 // Column span = 2, but control is in the last column, forces control back into 1st column, next row
\r
430 // I have no clue why c3 shouldn't be in (1,0), but MS says it's not
\r
431 TableLayoutPanel p = new TableLayoutPanel ();
\r
432 Control c1 = new Button ();
\r
433 Control c2 = new Button ();
\r
434 Control c3 = new Button ();
\r
439 p.SetColumnSpan (c2, 2);
\r
441 p.Controls.Add (c1);
\r
442 p.Controls.Add (c2);
\r
443 p.Controls.Add (c3);
\r
445 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
\r
446 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c2), "C2");
\r
447 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 2), p.GetPositionFromControl (c3), "C3");
\r
451 public void TestCellPositioning11 ()
\r
453 // Row span = 2, but control is in the last row, creates new row
\r
454 TableLayoutPanel p = new TableLayoutPanel ();
\r
455 Control c1 = new Button ();
\r
456 Control c2 = new Button ();
\r
457 Control c3 = new Button ();
\r
462 p.SetRowSpan (c3, 2);
\r
464 p.Controls.Add (c1);
\r
465 p.Controls.Add (c2);
\r
466 p.Controls.Add (c3);
\r
468 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
\r
469 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 0), p.GetPositionFromControl (c2), "C2");
\r
470 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c3), "C3");
\r
474 public void TestCellPositioning12 ()
\r
476 // Requesting a column greater than ColumnCount, request is ignored
\r
477 TableLayoutPanel p = new TableLayoutPanel ();
\r
478 Control c1 = new Button ();
\r
479 Control c2 = new Button ();
\r
480 Control c3 = new Button ();
\r
485 p.SetColumn (c1, 4);
\r
487 p.Controls.Add (c1);
\r
488 p.Controls.Add (c2);
\r
489 p.Controls.Add (c3);
\r
491 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
\r
492 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 0), p.GetPositionFromControl (c2), "C2");
\r
493 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c3), "C3");
\r
497 public void TestCellPositioning13 ()
\r
499 // Row span = 2, but control is in the last row, creates new row
\r
500 TableLayoutPanel p = new TableLayoutPanel ();
\r
501 Control c1 = new Button ();
\r
502 Control c2 = new Button ();
\r
503 Control c3 = new Button ();
\r
508 p.SetRowSpan (c3, 2);
\r
510 p.Controls.Add (c1);
\r
511 p.Controls.Add (c2);
\r
512 p.Controls.Add (c3);
\r
514 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
\r
515 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 0), p.GetPositionFromControl (c2), "C2");
\r
516 Assert.AreEqual (new TableLayoutPanelCellPosition (2, 0), p.GetPositionFromControl (c3), "C3");
\r
520 [Category ("NotWorking")]
\r
521 public void TestCellPositioning14 ()
\r
523 // Col span = 3, fixed grow style
\r
524 TableLayoutPanel p = new TableLayoutPanel ();
\r
525 p.GrowStyle = TableLayoutPanelGrowStyle.FixedSize;
\r
526 Control c1 = new Button ();
\r
531 p.SetColumnSpan (c1, 3);
\r
533 p.Controls.Add (c1);
\r
535 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
\r
539 public void TestCellPositioning15 ()
\r
541 // Column span = 2, but control is in the last column, forces control back into 1st column, next row
\r
542 // I have no clue why c3 shouldn't be in (1,0), but MS says it's not
\r
543 TableLayoutPanel p = new TableLayoutPanel ();
\r
544 Control c1 = new Button ();
\r
545 Control c2 = new Button ();
\r
546 Control c3 = new Button ();
\r
551 p.SetColumnSpan (c2, 2);
\r
552 p.SetCellPosition (c2, new TableLayoutPanelCellPosition (1, 0));
\r
554 p.Controls.Add (c1);
\r
555 p.Controls.Add (c2);
\r
556 p.Controls.Add (c3);
\r
558 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
\r
559 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c2), "C2");
\r
560 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 2), p.GetPositionFromControl (c3), "C3");
\r
564 public void TestCellPositioning16 ()
\r
566 // Row span = 2, but control is in the last row, creates new row
\r
567 TableLayoutPanel p = new TableLayoutPanel ();
\r
568 Control c1 = new Button ();
\r
569 Control c2 = new Button ();
\r
570 Control c3 = new Button ();
\r
575 p.SetRowSpan (c3, 2);
\r
576 p.SetCellPosition (c3, new TableLayoutPanelCellPosition (0, 1));
\r
578 p.Controls.Add (c1);
\r
579 p.Controls.Add (c2);
\r
580 p.Controls.Add (c3);
\r
582 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
\r
583 Assert.AreEqual (new TableLayoutPanelCellPosition (1, 0), p.GetPositionFromControl (c2), "C2");
\r
584 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c3), "C3");
\r
588 public void TestCellPositioning17 ()
\r
590 // ColumnCount == RowCount == 0, but control is added at > 0.
\r
591 // The columns and rows are created, but ColumnCount and RowCount remains 0
\r
593 TableLayoutPanel p = new TableLayoutPanel ();
\r
596 Control c1 = new Button ();
\r
598 p.Controls.Add (c1, 6, 7);
\r
599 Assert.AreEqual (new TableLayoutPanelCellPosition (6, 7), p.GetPositionFromControl (c1), "C1");
\r
600 Assert.AreEqual (0, p.LayoutSettings.ColumnCount, "C2");
\r
601 Assert.AreEqual (0, p.LayoutSettings.RowCount, "C3");
\r
605 public void TestCellPositioning18 ()
\r
607 // A control with both rowspan and columnspan > 1 was getting
\r
608 // other controls put into its extent (i.e. c3 was ending up
\r
609 // at (1,1) instead of (2,1).
\r
610 TableLayoutPanel p = new TableLayoutPanel ();
\r
611 Control c1 = new Button ();
\r
612 Control c2 = new Button ();
\r
613 Control c3 = new Button ();
\r
614 Control c4 = new Button ();
\r
619 p.SetRowSpan (c1, 2);
\r
620 p.SetColumnSpan (c1, 2);
\r
621 p.SetCellPosition (c1, new TableLayoutPanelCellPosition (0, 0));
\r
623 p.Controls.Add (c1);
\r
624 p.Controls.Add (c2);
\r
625 p.Controls.Add (c3);
\r
626 p.Controls.Add (c4);
\r
628 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
\r
629 Assert.AreEqual (new TableLayoutPanelCellPosition (2, 0), p.GetPositionFromControl (c2), "C2");
\r
630 Assert.AreEqual (new TableLayoutPanelCellPosition (2, 1), p.GetPositionFromControl (c3), "C3");
\r
631 Assert.AreEqual (new TableLayoutPanelCellPosition (0, 2), p.GetPositionFromControl (c4), "C4");
\r
635 public void TestRowColumnSizes1 ()
\r
637 // Row span = 2, but control is in the last row, creates new row
\r
638 TableLayoutPanel p = new TableLayoutPanel ();
\r
639 Control c1 = new Button ();
\r
640 Control c2 = new Button ();
\r
641 Control c3 = new Button ();
\r
646 p.RowStyles.Add (new RowStyle (SizeType.Percent, 100F));
\r
648 p.Controls.Add (c1);
\r
649 p.Controls.Add (c2);
\r
650 p.Controls.Add (c3);
\r
652 Assert.AreEqual (71, p.GetRowHeights ()[0], "D1");
\r
653 Assert.AreEqual (29, p.GetRowHeights ()[1], "D2");
\r
657 public void TestRowColumnSizes2 ()
\r
659 // Row span = 2, but control is in the last row, creates new row
\r
660 TableLayoutPanel p = new TableLayoutPanel ();
\r
661 Control c1 = new Button ();
\r
662 Control c2 = new Button ();
\r
663 Control c3 = new Button ();
\r
668 p.RowStyles.Add (new RowStyle (SizeType.Absolute, 100F));
\r
670 p.Controls.Add (c1);
\r
671 p.Controls.Add (c2);
\r
672 p.Controls.Add (c3);
\r
674 Assert.AreEqual (100, p.GetRowHeights ()[0], "D1");
\r
675 Assert.AreEqual (29, p.GetRowHeights ()[1], "D2");
\r
679 public void TestRowColumnSizes3 ()
\r
681 // Row span = 2, but control is in the last row, creates new row
\r
682 TableLayoutPanel p = new TableLayoutPanel ();
\r
683 Control c1 = new Button ();
\r
684 Control c2 = new Button ();
\r
685 Control c3 = new Button ();
\r
686 Control c4 = new Button ();
\r
687 Control c5 = new Button ();
\r
692 p.RowStyles.Add (new RowStyle (SizeType.Percent, 100F));
\r
694 p.Controls.Add (c1);
\r
695 p.Controls.Add (c2);
\r
696 p.Controls.Add (c3);
\r
697 p.Controls.Add (c4);
\r
698 p.Controls.Add (c5);
\r
700 Assert.AreEqual (42, p.GetRowHeights ()[0], "D1");
\r
701 Assert.AreEqual (29, p.GetRowHeights ()[1], "D2");
\r
702 Assert.AreEqual (29, p.GetRowHeights ()[2], "D3");
\r
706 public void TestRowColumnSizes4 ()
\r
708 // Row span = 2, but control is in the last row, creates new row
\r
709 TableLayoutPanel p = new TableLayoutPanel ();
\r
710 Control c1 = new Button ();
\r
711 Control c2 = new Button ();
\r
712 Control c3 = new Button ();
\r
713 Control c4 = new Button ();
\r
714 Control c5 = new Button ();
\r
715 Control c6 = new Button ();
\r
716 Control c7 = new Button ();
\r
721 p.RowStyles.Add (new RowStyle (SizeType.Percent, 100F));
\r
723 p.Controls.Add (c1);
\r
724 p.Controls.Add (c2);
\r
725 p.Controls.Add (c3);
\r
726 p.Controls.Add (c4);
\r
727 p.Controls.Add (c5);
\r
728 p.Controls.Add (c6);
\r
729 p.Controls.Add (c7);
\r
731 //Assert.AreEqual (100, p.GetRowHeights ()[0], "D1");
\r
732 Assert.AreEqual (29, p.GetRowHeights ()[1], "D2");
\r
733 Assert.AreEqual (29, p.GetRowHeights ()[2], "D3");
\r
734 Assert.AreEqual (29, p.GetRowHeights ()[3], "D4");
\r
738 public void TestRowColumnSizes5 ()
\r
740 // 2 Absolute Columns/Rows
\r
741 TableLayoutPanel p = new TableLayoutPanel ();
\r
742 Control c1 = new Button ();
\r
743 Control c2 = new Button ();
\r
744 Control c3 = new Button ();
\r
749 p.RowStyles.Add (new RowStyle (SizeType.Absolute, 20));
\r
750 p.RowStyles.Add (new RowStyle (SizeType.Absolute, 30));
\r
751 p.ColumnStyles.Add (new ColumnStyle (SizeType.Absolute, 20));
\r
752 p.ColumnStyles.Add (new ColumnStyle (SizeType.Absolute, 30));
\r
754 p.Controls.Add (c1);
\r
755 p.Controls.Add (c2);
\r
756 p.Controls.Add (c3);
\r
758 Assert.AreEqual (20, p.GetRowHeights ()[0], "D1");
\r
759 Assert.AreEqual (80, p.GetRowHeights ()[1], "D2");
\r
760 Assert.AreEqual (20, p.GetColumnWidths ()[0], "D3");
\r
761 Assert.AreEqual (180, p.GetColumnWidths ()[1], "D4");
\r
765 public void TestRowColumnSizes6 ()
\r
767 // 2 50% Columns/Rows
\r
768 TableLayoutPanel p = new TableLayoutPanel ();
\r
769 Control c1 = new Button ();
\r
770 Control c2 = new Button ();
\r
771 Control c3 = new Button ();
\r
776 p.RowStyles.Add (new RowStyle (SizeType.Percent, 50));
\r
777 p.RowStyles.Add (new RowStyle (SizeType.Percent, 50));
\r
778 p.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 50));
\r
779 p.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 50));
\r
781 p.Controls.Add (c1);
\r
782 p.Controls.Add (c2);
\r
783 p.Controls.Add (c3);
\r
785 Assert.AreEqual (50, p.GetRowHeights ()[0], "D1");
\r
786 Assert.AreEqual (50, p.GetRowHeights ()[1], "D2");
\r
787 Assert.AreEqual (100, p.GetColumnWidths ()[0], "D3");
\r
788 Assert.AreEqual (100, p.GetColumnWidths ()[1], "D4");
\r
792 public void TestRowColumnSizes7 ()
\r
794 // 1 Absolute and 2 Percent Columns/Rows
\r
795 TableLayoutPanel p = new TableLayoutPanel ();
\r
796 Control c1 = new Button ();
\r
797 Control c2 = new Button ();
\r
798 Control c3 = new Button ();
\r
803 p.RowStyles.Add (new RowStyle (SizeType.Absolute, 50));
\r
804 p.RowStyles.Add (new RowStyle (SizeType.Percent, 50));
\r
805 p.RowStyles.Add (new RowStyle (SizeType.Percent, 50));
\r
806 p.ColumnStyles.Add (new ColumnStyle (SizeType.Absolute, 50));
\r
807 p.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 50));
\r
808 p.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 50));
\r
810 p.Controls.Add (c1);
\r
811 p.Controls.Add (c2);
\r
812 p.Controls.Add (c3);
\r
814 Assert.AreEqual (50, p.GetRowHeights ()[0], "D1");
\r
815 Assert.AreEqual (25, p.GetRowHeights ()[1], "D2");
\r
816 Assert.AreEqual (25, p.GetRowHeights ()[2], "D3");
\r
817 Assert.AreEqual (50, p.GetColumnWidths ()[0], "D4");
\r
818 Assert.AreEqual (75, p.GetColumnWidths ()[1], "D5");
\r
819 Assert.AreEqual (75, p.GetColumnWidths ()[2], "D6");
\r
823 public void TestRowColumnSizes8 ()
\r
825 // 1 Absolute and 2 Percent Columns/Rows (with total percents > 100)
\r
826 TableLayoutPanel p = new TableLayoutPanel ();
\r
827 Control c1 = new Button ();
\r
828 Control c2 = new Button ();
\r
829 Control c3 = new Button ();
\r
834 p.RowStyles.Add (new RowStyle (SizeType.Absolute, 50));
\r
835 p.RowStyles.Add (new RowStyle (SizeType.Percent, 100));
\r
836 p.RowStyles.Add (new RowStyle (SizeType.Percent, 100));
\r
837 p.ColumnStyles.Add (new ColumnStyle (SizeType.Absolute, 50));
\r
838 p.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 100));
\r
839 p.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 100));
\r
841 p.Controls.Add (c1);
\r
842 p.Controls.Add (c2);
\r
843 p.Controls.Add (c3);
\r
845 Assert.AreEqual (50, p.GetRowHeights ()[0], "D1");
\r
846 Assert.AreEqual (25, p.GetRowHeights ()[1], "D2");
\r
847 Assert.AreEqual (25, p.GetRowHeights ()[2], "D3");
\r
848 Assert.AreEqual (50, p.GetColumnWidths ()[0], "D4");
\r
849 Assert.AreEqual (75, p.GetColumnWidths ()[1], "D5");
\r
850 Assert.AreEqual (75, p.GetColumnWidths ()[2], "D6");
\r
854 public void TestRowColumnSizes9 ()
\r
856 // 1 Absolute and 2 Percent Columns/Rows (with total percents > 100)
\r
857 TableLayoutPanel p = new TableLayoutPanel ();
\r
858 Control c1 = new Button ();
\r
859 Control c2 = new Button ();
\r
860 Control c3 = new Button ();
\r
865 p.RowStyles.Add (new RowStyle (SizeType.Absolute, 50));
\r
866 p.RowStyles.Add (new RowStyle (SizeType.Percent, 80));
\r
867 p.RowStyles.Add (new RowStyle (SizeType.Percent, 40));
\r
868 p.ColumnStyles.Add (new ColumnStyle (SizeType.Absolute, 50));
\r
869 p.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 80));
\r
870 p.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 40));
\r
872 p.Controls.Add (c1);
\r
873 p.Controls.Add (c2);
\r
874 p.Controls.Add (c3);
\r
876 Assert.AreEqual (50, p.GetRowHeights ()[0], "D1");
\r
877 Assert.AreEqual (33, p.GetRowHeights ()[1], "D2");
\r
878 Assert.AreEqual (17, p.GetRowHeights ()[2], "D3");
\r
879 Assert.AreEqual (50, p.GetColumnWidths ()[0], "D4");
\r
880 Assert.AreEqual (100, p.GetColumnWidths ()[1], "D5");
\r
881 Assert.AreEqual (50, p.GetColumnWidths ()[2], "D6");
\r
885 public void TestRowColumnSizes10 ()
\r
887 // 2 AutoSize Columns/Rows
\r
888 TableLayoutPanel p = new TableLayoutPanel ();
\r
889 Control c1 = new Button ();
\r
890 Control c2 = new Button ();
\r
891 Control c3 = new Button ();
\r
896 p.RowStyles.Add (new RowStyle (SizeType.AutoSize));
\r
897 p.RowStyles.Add (new RowStyle (SizeType.AutoSize));
\r
898 p.ColumnStyles.Add (new ColumnStyle (SizeType.AutoSize));
\r
899 p.ColumnStyles.Add (new ColumnStyle (SizeType.AutoSize));
\r
901 p.Controls.Add (c1);
\r
902 p.Controls.Add (c2);
\r
903 p.Controls.Add (c3);
\r
905 Assert.AreEqual (29, p.GetRowHeights ()[0], "D1");
\r
906 Assert.AreEqual (71, p.GetRowHeights ()[1], "D2");
\r
907 Assert.AreEqual (81, p.GetColumnWidths ()[0], "D3");
\r
908 Assert.AreEqual (119, p.GetColumnWidths ()[1], "D4");
\r
912 public void TestRowColumnSizes11 ()
\r
914 // AutoSize Columns/Rows, and column-spanning controls, but
\r
915 // no control starts in column 1.
\r
916 // Mono's old behavior was for column 1 to have a zero width.
\r
917 TableLayoutPanel p = new TableLayoutPanel ();
\r
918 Control c1 = new Button ();
\r
919 Control c2 = new Button ();
\r
920 Control c3 = new Button ();
\r
922 c1.Size = new Size (150, 25);
\r
923 c2.Size = new Size (75, 25);
\r
924 c3.Size = new Size (150, 25);
\r
929 p.RowStyles.Add (new RowStyle (SizeType.AutoSize));
\r
930 p.RowStyles.Add (new RowStyle (SizeType.AutoSize));
\r
931 p.RowStyles.Add (new RowStyle (SizeType.AutoSize));
\r
932 p.ColumnStyles.Add (new ColumnStyle (SizeType.AutoSize));
\r
933 p.ColumnStyles.Add (new ColumnStyle (SizeType.AutoSize));
\r
934 p.ColumnStyles.Add (new ColumnStyle (SizeType.AutoSize));
\r
935 p.ColumnStyles.Add (new ColumnStyle (SizeType.AutoSize));
\r
937 p.SetColumnSpan (c1, 2);
\r
938 p.SetColumnSpan (c3, 2);
\r
940 p.Controls.Add (c1, 0, 0);
\r
941 p.Controls.Add (c2, 0, 1);
\r
942 p.Controls.Add (c3, 1, 1);
\r
944 // The bug fix gets Mono to behave very closely to .NET,
\r
945 // but not exactly...3 pixels off somewhere...
\r
946 Assert.AreEqual (31, p.GetRowHeights ()[0], "D1");
\r
947 Assert.AreEqual (31, p.GetRowHeights ()[1], "D2");
\r
948 Assert.AreEqual (81, p.GetColumnWidths ()[0], "D3");
\r
949 Assert.LessOrEqual (75, p.GetColumnWidths ()[1], "D4");
\r
950 Assert.GreaterOrEqual (78, p.GetColumnWidths ()[1], "D5");
\r
951 Assert.LessOrEqual (78, p.GetColumnWidths ()[2], "D6");
\r
952 Assert.GreaterOrEqual (81, p.GetColumnWidths ()[2], "D7");
\r
956 public void Bug81843 ()
\r
958 Form f = new Form ();
\r
959 f.ShowInTaskbar = false;
\r
961 TableLayoutPanel tableLayoutPanel1;
\r
966 tableLayoutPanel1 = new TableLayoutPanel ();
\r
967 button2 = new Button ();
\r
968 button4 = new Button ();
\r
969 textBox1 = new TextBox ();
\r
970 tableLayoutPanel1.SuspendLayout ();
\r
971 f.SuspendLayout ();
\r
973 tableLayoutPanel1.AutoSize = true;
\r
974 tableLayoutPanel1.ColumnCount = 3;
\r
975 tableLayoutPanel1.ColumnStyles.Add (new ColumnStyle ());
\r
976 tableLayoutPanel1.ColumnStyles.Add (new ColumnStyle ());
\r
977 tableLayoutPanel1.ColumnStyles.Add (new ColumnStyle ());
\r
978 tableLayoutPanel1.Controls.Add (button2, 0, 1);
\r
979 tableLayoutPanel1.Controls.Add (button4, 2, 1);
\r
980 tableLayoutPanel1.Controls.Add (textBox1, 1, 0);
\r
981 tableLayoutPanel1.Location = new Point (0, 0);
\r
982 tableLayoutPanel1.RowCount = 2;
\r
983 tableLayoutPanel1.RowStyles.Add (new RowStyle (SizeType.Percent, 50F));
\r
984 tableLayoutPanel1.RowStyles.Add (new RowStyle (SizeType.Percent, 50F));
\r
985 tableLayoutPanel1.Size = new Size (292, 287);
\r
987 button2.Size = new Size (75, 23);
\r
989 button4.Size = new Size (75, 23);
\r
991 textBox1.Dock = DockStyle.Fill;
\r
992 textBox1.Location = new Point (84, 3);
\r
993 textBox1.Multiline = true;
\r
994 textBox1.Size = new Size (94, 137);
\r
996 f.ClientSize = new Size (292, 312);
\r
997 f.Controls.Add (tableLayoutPanel1);
\r
1000 tableLayoutPanel1.ResumeLayout (false);
\r
1001 tableLayoutPanel1.PerformLayout ();
\r
1002 f.ResumeLayout (false);
\r
1003 f.PerformLayout ();
\r
1007 Assert.AreEqual (new Rectangle (3, 146, 75, 23), button2.Bounds, "A1");
\r
1008 Assert.AreEqual (new Rectangle (184, 146, 75, 23), button4.Bounds, "A2");
\r
1009 Assert.AreEqual (new Rectangle (84, 3, 94, 137), textBox1.Bounds, "A3");
\r
1014 [Test] // From bug #81884
\r
1015 public void CellBorderStyle ()
\r
1017 Form f = new Form ();
\r
1018 f.ShowInTaskbar = false;
\r
1020 TableLayoutPanel p = new TableLayoutPanel ();
\r
1021 p = new TableLayoutPanel ();
\r
1022 p.ColumnCount = 3;
\r
1023 p.ColumnStyles.Add (new ColumnStyle ());
\r
1024 p.ColumnStyles.Add (new ColumnStyle ());
\r
1025 p.ColumnStyles.Add (new ColumnStyle ());
\r
1026 p.Dock = DockStyle.Top;
\r
1029 p.RowStyles.Add (new RowStyle (SizeType.Percent, 50F));
\r
1030 p.RowStyles.Add (new RowStyle (SizeType.Percent, 50F));
\r
1031 f.Controls.Add (p);
\r
1033 Label _labelA = new Label ();
\r
1034 _labelA.Dock = DockStyle.Fill;
\r
1035 _labelA.Size = new Size (95, 20);
\r
1036 _labelA.Text = "A";
\r
1037 p.Controls.Add (_labelA, 0, 0);
\r
1039 Label _labelB = new Label ();
\r
1040 _labelB.Dock = DockStyle.Fill;
\r
1041 _labelB.Size = new Size (95, 20);
\r
1042 _labelB.Text = "B";
\r
1043 p.Controls.Add (_labelB, 1, 0);
\r
1045 Label _labelC = new Label ();
\r
1046 _labelC.Dock = DockStyle.Fill;
\r
1047 _labelC.Size = new Size (95, 20);
\r
1048 _labelC.Text = "C";
\r
1049 p.Controls.Add (_labelC, 2, 0);
\r
1051 Label _labelD = new Label ();
\r
1052 _labelD.Dock = DockStyle.Fill;
\r
1053 _labelD.Size = new Size (95, 20);
\r
1054 _labelD.Text = "D";
\r
1055 p.Controls.Add (_labelD, 0, 1);
\r
1057 Label _labelE = new Label ();
\r
1058 _labelE.Dock = DockStyle.Fill;
\r
1059 _labelE.Size = new Size (95, 20);
\r
1060 _labelE.Text = "E";
\r
1061 p.Controls.Add (_labelE, 1, 1);
\r
1063 Label _labelF = new Label ();
\r
1064 _labelF.Dock = DockStyle.Fill;
\r
1065 _labelF.Size = new Size (95, 20);
\r
1066 _labelF.Text = "F";
\r
1067 p.Controls.Add (_labelF, 2, 1);
\r
1069 _labelA.BackColor = Color.Red;
\r
1070 _labelB.BackColor = Color.Orange;
\r
1071 _labelC.BackColor = Color.Yellow;
\r
1072 _labelD.BackColor = Color.Green;
\r
1073 _labelE.BackColor = Color.Blue;
\r
1074 _labelF.BackColor = Color.Purple;
\r
1078 Assert.AreEqual (new Rectangle (3, 0, 95, 100), _labelA.Bounds, "A1");
\r
1079 Assert.AreEqual (new Rectangle (104, 0, 95, 100), _labelB.Bounds, "A2");
\r
1080 Assert.AreEqual (new Rectangle (205, 0, 95, 100), _labelC.Bounds, "A3");
\r
1081 Assert.AreEqual (new Rectangle (3, 100, 95, 100), _labelD.Bounds, "A4");
\r
1082 Assert.AreEqual (new Rectangle (104, 100, 95, 100), _labelE.Bounds, "A5");
\r
1083 Assert.AreEqual (new Rectangle (205, 100, 95, 100), _labelF.Bounds, "A6");
\r
1085 p.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single;
\r
1086 Assert.AreEqual (new Rectangle (4, 1, 95, 98), _labelA.Bounds, "A7");
\r
1087 Assert.AreEqual (new Rectangle (106, 1, 95, 98), _labelB.Bounds, "A8");
\r
1088 Assert.AreEqual (new Rectangle (208, 1, 95, 98), _labelC.Bounds, "A9");
\r
1089 Assert.AreEqual (new Rectangle (4, 100, 95, 99), _labelD.Bounds, "A10");
\r
1090 Assert.AreEqual (new Rectangle (106, 100, 95, 99), _labelE.Bounds, "A11");
\r
1091 Assert.AreEqual (new Rectangle (208, 100, 95, 99), _labelF.Bounds, "A12");
\r
1093 p.CellBorderStyle = TableLayoutPanelCellBorderStyle.Inset;
\r
1094 Assert.AreEqual (new Rectangle (5, 2, 95, 97), _labelA.Bounds, "A13");
\r
1095 Assert.AreEqual (new Rectangle (108, 2, 95, 97), _labelB.Bounds, "A14");
\r
1096 Assert.AreEqual (new Rectangle (211, 2, 95, 97), _labelC.Bounds, "A15");
\r
1097 Assert.AreEqual (new Rectangle (5, 101, 95, 97), _labelD.Bounds, "A16");
\r
1098 Assert.AreEqual (new Rectangle (108, 101, 95, 97), _labelE.Bounds, "A17");
\r
1099 Assert.AreEqual (new Rectangle (211, 101, 95, 97), _labelF.Bounds, "A18");
\r
1101 p.CellBorderStyle = TableLayoutPanelCellBorderStyle.InsetDouble;
\r
1102 Assert.AreEqual (new Rectangle (6, 3, 95, 95), _labelA.Bounds, "A19");
\r
1103 Assert.AreEqual (new Rectangle (110, 3, 95, 95), _labelB.Bounds, "A20");
\r
1104 Assert.AreEqual (new Rectangle (214, 3, 95, 95), _labelC.Bounds, "A21");
\r
1105 Assert.AreEqual (new Rectangle (6, 101, 95, 96), _labelD.Bounds, "A22");
\r
1106 Assert.AreEqual (new Rectangle (110, 101, 95, 96), _labelE.Bounds, "A23");
\r
1107 Assert.AreEqual (new Rectangle (214, 101, 95, 96), _labelF.Bounds, "A24");
\r
1109 p.CellBorderStyle = TableLayoutPanelCellBorderStyle.Outset;
\r
1110 Assert.AreEqual (new Rectangle (5, 2, 95, 97), _labelA.Bounds, "A25");
\r
1111 Assert.AreEqual (new Rectangle (108, 2, 95, 97), _labelB.Bounds, "A26");
\r
1112 Assert.AreEqual (new Rectangle (211, 2, 95, 97), _labelC.Bounds, "A27");
\r
1113 Assert.AreEqual (new Rectangle (5, 101, 95, 97), _labelD.Bounds, "A28");
\r
1114 Assert.AreEqual (new Rectangle (108, 101, 95, 97), _labelE.Bounds, "A29");
\r
1115 Assert.AreEqual (new Rectangle (211, 101, 95, 97), _labelF.Bounds, "A30");
\r
1117 p.CellBorderStyle = TableLayoutPanelCellBorderStyle.OutsetDouble;
\r
1118 Assert.AreEqual (new Rectangle (6, 3, 95, 95), _labelA.Bounds, "A31");
\r
1119 Assert.AreEqual (new Rectangle (110, 3, 95, 95), _labelB.Bounds, "A32");
\r
1120 Assert.AreEqual (new Rectangle (214, 3, 95, 95), _labelC.Bounds, "A33");
\r
1121 Assert.AreEqual (new Rectangle (6, 101, 95, 96), _labelD.Bounds, "A34");
\r
1122 Assert.AreEqual (new Rectangle (110, 101, 95, 96), _labelE.Bounds, "A35");
\r
1123 Assert.AreEqual (new Rectangle (214, 101, 95, 96), _labelF.Bounds, "A36");
\r
1125 p.CellBorderStyle = TableLayoutPanelCellBorderStyle.OutsetPartial;
\r
1126 Assert.AreEqual (new Rectangle (6, 3, 95, 95), _labelA.Bounds, "A37");
\r
1127 Assert.AreEqual (new Rectangle (110, 3, 95, 95), _labelB.Bounds, "A38");
\r
1128 Assert.AreEqual (new Rectangle (214, 3, 95, 95), _labelC.Bounds, "A39");
\r
1129 Assert.AreEqual (new Rectangle (6, 101, 95, 96), _labelD.Bounds, "A40");
\r
1130 Assert.AreEqual (new Rectangle (110, 101, 95, 96), _labelE.Bounds, "A41");
\r
1131 Assert.AreEqual (new Rectangle (214, 101, 95, 96), _labelF.Bounds, "A42");
\r
1137 public void Bug81936 ()
\r
1139 Form f = new Form ();
\r
1140 f.ShowInTaskbar = false;
\r
1142 TableLayoutPanel tableLayoutPanel1;
\r
1146 tableLayoutPanel1 = new TableLayoutPanel ();
\r
1147 button2 = new Label ();
\r
1148 button4 = new Label ();
\r
1149 button2.Text = "Test1";
\r
1150 button4.Text = "Test2";
\r
1151 button2.Anchor = AnchorStyles.Left;
\r
1152 button4.Anchor = AnchorStyles.Left;
\r
1153 button2.Height = 14;
\r
1154 button4.Height = 14;
\r
1155 tableLayoutPanel1.SuspendLayout ();
\r
1156 f.SuspendLayout ();
\r
1158 tableLayoutPanel1.ColumnCount = 1;
\r
1159 tableLayoutPanel1.ColumnStyles.Add (new ColumnStyle ());
\r
1160 tableLayoutPanel1.Controls.Add (button2, 0, 0);
\r
1161 tableLayoutPanel1.Controls.Add (button4, 0, 1);
\r
1162 tableLayoutPanel1.Location = new Point (0, 0);
\r
1163 tableLayoutPanel1.RowCount = 2;
\r
1164 tableLayoutPanel1.RowStyles.Add (new RowStyle (SizeType.Absolute, 28F));
\r
1165 tableLayoutPanel1.RowStyles.Add (new RowStyle (SizeType.Absolute, 28F));
\r
1166 tableLayoutPanel1.Size = new Size (292, 56);
\r
1168 f.ClientSize = new Size (292, 312);
\r
1169 f.Controls.Add (tableLayoutPanel1);
\r
1172 tableLayoutPanel1.ResumeLayout (false);
\r
1173 tableLayoutPanel1.PerformLayout ();
\r
1174 f.ResumeLayout (false);
\r
1175 f.PerformLayout ();
\r
1179 Assert.AreEqual (new Rectangle (3, 7, 100, 14), button2.Bounds, "A1");
\r
1180 Assert.AreEqual (new Rectangle (3, 35, 100, 14), button4.Bounds, "A2");
\r
1186 public void Bug82605 ()
\r
1188 Form f = new Form ();
\r
1189 f.ShowInTaskbar = false;
\r
1191 Label l = new Label ();
\r
1193 TableLayoutPanel table = new TableLayoutPanel ();
\r
1194 table.ColumnCount = 1;
\r
1195 table.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 100F));
\r
1197 table.RowCount = 2;
\r
1198 table.RowStyles.Add (new RowStyle (SizeType.Percent, 100F));
\r
1199 table.RowStyles.Add (new RowStyle (SizeType.Absolute, 20F));
\r
1201 table.Controls.Add (l, 0, 1);
\r
1202 table.Location = new Point (0, 0);
\r
1203 table.Width = 250;
\r
1205 l.Anchor = AnchorStyles.Left | AnchorStyles.Right;
\r
1206 l.AutoSize = true;
\r
1207 l.Location = new Point (3, 352);
\r
1208 l.Size = new Size (578, 13);
\r
1209 l.Text = "label1";
\r
1210 l.TextAlign = ContentAlignment.MiddleCenter;
\r
1212 f.Controls.Add (table);
\r
1215 // Height is font dependent, but this bug is about the width anyways
\r
1216 Assert.AreEqual (244, l.Width, "A1");
\r
1221 [Test] // bug #82040
\r
1222 public void ShowNoChildren ()
\r
1224 Form form = new Form ();
\r
1225 form.ShowInTaskbar = false;
\r
1227 TableLayoutPanel tableLayoutPanel = new TableLayoutPanel ();
\r
1228 tableLayoutPanel.ColumnCount = 3;
\r
1229 tableLayoutPanel.Dock = DockStyle.Fill;
\r
1230 tableLayoutPanel.RowCount = 11;
\r
1231 form.Controls.Add (tableLayoutPanel);
\r
1238 [Test] // bug #82041
\r
1239 public void DontCallResumeLayout ()
\r
1241 Form form = new Form ();
\r
1242 form.ShowInTaskbar = false;
\r
1244 TableLayoutPanel tableLayoutPanel = new TableLayoutPanel ();
\r
1245 form.Controls.Add (tableLayoutPanel);
\r
1246 tableLayoutPanel.SuspendLayout ();
\r
1247 tableLayoutPanel.ColumnCount = 3;
\r
1248 tableLayoutPanel.Dock = DockStyle.Fill;
\r
1249 tableLayoutPanel.RowCount = 11;
\r
1250 tableLayoutPanel.Controls.Add (new Button ());
\r
1257 [Test] // bug #346246
\r
1258 public void AutoSizePanelVertical ()
\r
1260 Form f = new Form ();
\r
1261 f.ShowInTaskbar = false;
\r
1263 TableLayoutPanel tlp = new TableLayoutPanel ();
\r
1264 tlp.AutoSize = true;
\r
1265 tlp.AutoSizeMode = AutoSizeMode.GrowAndShrink;
\r
1266 tlp.ColumnCount = 1;
\r
1267 tlp.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 100F));
\r
1268 tlp.Location = new Point (12, 12);
\r
1269 tlp.Name = "tableLayoutPanel1";
\r
1271 tlp.RowStyles.Add (new RowStyle (SizeType.Percent, 50F));
\r
1272 tlp.RowStyles.Add (new RowStyle (SizeType.Percent, 50F));
\r
1273 tlp.Size = new Size (139, 182);
\r
1276 f.Controls.Add (tlp);
\r
1278 Button b = new Button ();
\r
1279 b.Size = new Size (100, 100);
\r
1280 tlp.Controls.Add (b, 0, 0);
\r
1282 PictureBox p = new PictureBox ();
\r
1283 p.Size = new Size (100, 100);
\r
1284 tlp.Controls.Add (p,0,1);
\r
1288 Assert.AreEqual (new Rectangle (12, 12, 106, 212), tlp.Bounds, "A1");
\r
1289 Assert.AreEqual (new Rectangle (3, 3, 100, 100), b.Bounds, "A2");
\r
1290 Assert.AreEqual (new Rectangle (3, 109, 100, 100), p.Bounds, "A3");
\r
1295 Assert.AreEqual (new Rectangle (12, 12, 126, 252), tlp.Bounds, "B1");
\r
1296 Assert.AreEqual (new Rectangle (3, 3, 120, 120), b.Bounds, "B2");
\r
1297 Assert.AreEqual (new Rectangle (3, 129, 100, 100), p.Bounds, "B3");
\r
1302 Assert.AreEqual (new Rectangle (12, 12, 126, 252), tlp.Bounds, "C1");
\r
1303 Assert.AreEqual (new Rectangle (3, 3, 120, 120), b.Bounds, "C2");
\r
1304 Assert.AreEqual (new Rectangle (3, 129, 120, 120), p.Bounds, "C3");
\r
1309 [Test] // bug #346246
\r
1310 public void AutoSizePanelHorizontal ()
\r
1312 Form f = new Form ();
\r
1313 f.ShowInTaskbar = false;
\r
1315 TableLayoutPanel tlp = new TableLayoutPanel ();
\r
1316 tlp.AutoSize = true;
\r
1317 tlp.AutoSizeMode = AutoSizeMode.GrowAndShrink;
\r
1318 tlp.ColumnCount = 2;
\r
1319 tlp.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 50F));
\r
1320 tlp.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 50F));
\r
1321 tlp.Location = new Point (12, 12);
\r
1322 tlp.Name = "tableLayoutPanel1";
\r
1324 tlp.RowStyles.Add (new RowStyle (SizeType.Percent, 100F));
\r
1325 tlp.Size = new Size (139, 182);
\r
1328 f.Controls.Add (tlp);
\r
1330 Button b = new Button ();
\r
1331 b.Size = new Size (100, 100);
\r
1332 tlp.Controls.Add (b, 0, 0);
\r
1334 PictureBox p = new PictureBox ();
\r
1335 p.Size = new Size (100, 100);
\r
1336 tlp.Controls.Add (p, 1, 0);
\r
1340 Assert.AreEqual (new Rectangle (12, 12, 212, 106), tlp.Bounds, "A1");
\r
1341 Assert.AreEqual (new Rectangle (3, 3, 100, 100), b.Bounds, "A2");
\r
1342 Assert.AreEqual (new Rectangle (109, 3, 100, 100), p.Bounds, "A3");
\r
1347 Assert.AreEqual (new Rectangle (12, 12, 252, 126), tlp.Bounds, "B1");
\r
1348 Assert.AreEqual (new Rectangle (3, 3, 120, 120), b.Bounds, "B2");
\r
1349 Assert.AreEqual (new Rectangle (129, 3, 100, 100), p.Bounds, "B3");
\r
1354 Assert.AreEqual (new Rectangle (12, 12, 252, 126), tlp.Bounds, "C1");
\r
1355 Assert.AreEqual (new Rectangle (3, 3, 120, 120), b.Bounds, "C2");
\r
1356 Assert.AreEqual (new Rectangle (129, 3, 120, 120), p.Bounds, "C3");
\r
1362 public void Bug354676 ()
\r
1364 Form f = new Form ();
\r
1366 TableLayoutPanel tlp = new TableLayoutPanel ();
\r
1367 tlp.Dock = DockStyle.Fill;
\r
1368 tlp.Padding = new Padding (40);
\r
1370 tlp.ColumnCount = 1;
\r
1371 f.Controls.Add (tlp);
\r
1373 Button b1 = new Button ();
\r
1374 tlp.Controls.Add (b1);
\r
1376 Button b2 = new Button ();
\r
1377 tlp.Controls.Add (b2);
\r
1381 Assert.AreEqual (new Rectangle (43, 43, 75, 23), b1.Bounds, "A1");
\r
1382 Assert.AreEqual (new Rectangle (43, 72, 75, 23), b2.Bounds, "A2");
\r
1389 public void Bug355408 ()
\r
1391 Form f = new Form ();
\r
1392 f.ClientSize = new Size (300, 300);
\r
1394 TableLayoutPanel tlp = new TableLayoutPanel ();
\r
1395 tlp.Dock = DockStyle.Fill;
\r
1397 tlp.ColumnCount = 2;
\r
1398 f.Controls.Add (tlp);
\r
1400 Button b1 = new Button ();
\r
1401 tlp.Controls.Add (b1);
\r
1403 Button b2 = new Button ();
\r
1404 tlp.Controls.Add (b2);
\r
1406 Button b3 = new Button ();
\r
1407 b3.Dock = DockStyle.Fill;
\r
1409 tlp.SetColumnSpan (b3, 2);
\r
1410 tlp.Controls.Add (b3);
\r
1414 Assert.AreEqual (new Rectangle (3, 3, 75, 23), b1.Bounds, "A1");
\r
1415 Assert.AreEqual (new Rectangle (84, 3, 75, 23), b2.Bounds, "A2");
\r
1416 Assert.AreEqual (new Rectangle (3, 32, 294, 265), b3.Bounds, "A3");
\r
1423 public void Bug402651 ()
\r
1425 Form f = new Form ();
\r
1426 f.ClientSize = new Size (300, 300);
\r
1428 TableLayoutPanel tlp = new TableLayoutPanel ();
\r
1429 tlp.Dock = DockStyle.Fill;
\r
1431 tlp.RowStyles.Add (new RowStyle (SizeType.Percent, 100F));
\r
1432 tlp.RowStyles.Add (new RowStyle (SizeType.AutoSize));
\r
1433 f.Controls.Add (tlp);
\r
1435 Button b1 = new Button ();
\r
1436 b1.Text = String.Empty;
\r
1437 b1.Dock = DockStyle.Fill;
\r
1438 tlp.Controls.Add (b1, 0, 0);
\r
1440 Button b2 = new Button ();
\r
1441 b2.Text = String.Empty;
\r
1442 b2.Size = new Size (100, 100);
\r
1443 b2.Anchor = AnchorStyles.None;
\r
1444 b2.Dock = DockStyle.None;
\r
1445 b2.Visible = false;
\r
1446 tlp.Controls.Add (b2, 0, 1);
\r
1450 b2.Visible = true;
\r
1451 Assert.AreEqual (new Size (100, 100), b2.Size, "A1");
\r
1453 b2.Visible = false;
\r
1454 b2.Anchor = AnchorStyles.Left;
\r
1455 b2.Visible = true;
\r
1456 Assert.AreEqual (new Size (100, 100), b2.Size, "A2");
\r
1462 public void Bug354672 ()
\r
1464 Form f = new Form ();
\r
1465 f.ClientSize = new Size (300, 300);
\r
1467 TableLayoutPanel tlp = new TableLayoutPanel ();
\r
1468 tlp.AutoSize = true;
\r
1469 tlp.ColumnCount = 2;
\r
1471 f.Controls.Add (tlp);
\r
1473 TextBox t1 = new TextBox ();
\r
1474 t1.Dock = DockStyle.Fill;
\r
1475 tlp.Controls.Add (t1);
\r
1477 TextBox t2 = new TextBox ();
\r
1478 t2.Dock = DockStyle.Fill;
\r
1479 tlp.Controls.Add (t2);
\r
1481 Assert.AreEqual (new Size (212, t1.Height + 6), tlp.PreferredSize, "A1");
\r
1487 public void Bug354672More ()
\r
1489 Form f = new Form ();
\r
1490 f.ClientSize = new Size (300, 300);
\r
1492 TableLayoutPanel tlp = new TableLayoutPanel ();
\r
1493 tlp.AutoSize = true;
\r
1494 tlp.ColumnCount = 2;
\r
1496 tlp.ColumnStyles.Add (new ColumnStyle (SizeType.AutoSize));
\r
1497 tlp.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 50f));
\r
1499 f.Controls.Add (tlp);
\r
1501 TextBox t1 = new TextBox ();
\r
1502 t1.Dock = DockStyle.Fill;
\r
1503 tlp.Controls.Add (t1);
\r
1505 TextBox t2 = new TextBox ();
\r
1506 t2.Dock = DockStyle.Fill;
\r
1507 tlp.Controls.Add (t2);
\r
1509 Assert.AreEqual (new Size (212, t1.Height + 6), tlp.PreferredSize, "A1");
\r
1515 public void Bug367249 ()
\r
1517 // Setting a colspan greater than the number of columns was
\r
1518 // causing an IOORE, this test just should not exception
\r
1519 TableLayoutPanel LayoutPanel = new TableLayoutPanel ();
\r
1520 LayoutPanel.ColumnCount = 1;
\r
1521 LayoutPanel.RowCount = 2;
\r
1523 Button OkButton = new Button ();
\r
1524 OkButton.Text = "OK";
\r
1525 LayoutPanel.Controls.Add (OkButton);
\r
1526 LayoutPanel.SetColumnSpan (OkButton, 3);
\r
1530 public void Bug396141 ()
\r
1532 // The issue is the user has set the RowCount to 0, but after
\r
1533 // we arrange the controls, we have 1 row. GetPreferredSize (for
\r
1534 // AutoSize) was using 0 instead of 1.
\r
1536 Form f = new Form ();
\r
1537 f.ClientSize = new Size (300, 300);
\r
1538 f.ShowInTaskbar = false;
\r
1540 TableLayoutPanel tlp = new TableLayoutPanel ();
\r
1541 tlp.AutoSize = true;
\r
1542 tlp.AutoSizeMode = AutoSizeMode.GrowAndShrink;
\r
1543 tlp.ColumnCount = 2;
\r
1546 f.Controls.Add (tlp);
\r
1548 TextBox t1 = new TextBox ();
\r
1549 t1.Dock = DockStyle.Fill;
\r
1550 tlp.Controls.Add (t1);
\r
1552 TextBox t2 = new TextBox ();
\r
1553 t2.Dock = DockStyle.Fill;
\r
1554 tlp.Controls.Add (t2);
\r
1558 Assert.IsTrue (tlp.Height > 0, "Height must be > 0");
\r
1559 Assert.IsTrue (tlp.Width > 0, "Width must be > 0");
\r
1565 public void Bug396433 ()
\r
1567 // We were not taking the CellBorderStyle into account when calculating
\r
1568 // the preferred size.
\r
1569 Form f = new Form ();
\r
1570 f.ClientSize = new Size (300, 300);
\r
1571 f.ShowInTaskbar = false;
\r
1573 TableLayoutPanel tlp = new TableLayoutPanel ();
\r
1574 tlp.AutoSize = true;
\r
1575 tlp.AutoSizeMode = AutoSizeMode.GrowAndShrink;
\r
1576 tlp.ColumnCount = 2;
\r
1579 f.Controls.Add (tlp);
\r
1581 Button t1 = new Button ();
\r
1582 tlp.Controls.Add (t1);
\r
1584 Button t2 = new Button ();
\r
1585 tlp.Controls.Add (t2);
\r
1589 Assert.AreEqual (new Size (162, 29), tlp.PreferredSize, "A1");
\r
1591 tlp.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single;
\r
1593 Assert.AreEqual (new Size (165, 31), tlp.PreferredSize, "A2");
\r
1599 public void IgnoreAutoSizeMode ()
\r
1601 // It would seem that AutoSizeMode for a TableLayoutPanel is always
\r
1602 // treated as GrowAndShrink
\r
1603 Form f = new Form ();
\r
1604 f.ClientSize = new Size (300, 300);
\r
1605 f.ShowInTaskbar = false;
\r
1607 TableLayoutPanel tlp = new TableLayoutPanel ();
\r
1608 tlp.AutoSize = true;
\r
1609 tlp.Dock = DockStyle.Top;
\r
1610 tlp.ColumnCount = 1;
\r
1613 f.Controls.Add (tlp);
\r
1615 Button t1 = new Button ();
\r
1616 tlp.Controls.Add (t1);
\r
1620 Assert.AreEqual (29, tlp.Height, "A1");
\r
1622 tlp.AutoSizeMode = AutoSizeMode.GrowAndShrink;
\r
1624 Assert.AreEqual (29, tlp.Height, "A2");
\r
1630 public void TestTableLayoutStyleOwned ()
\r
1633 ColumnStyle style = new ColumnStyle ();
\r
1634 TableLayoutColumnStyleCollection coll = new TableLayoutPanel ().ColumnStyles;
\r
1636 TableLayoutColumnStyleCollection coll2 = new TableLayoutPanel ().ColumnStyles;
\r
1637 coll2.Add (style);
\r
1638 Assert.Fail ("#1");
\r
1639 } catch (ArgumentException ex) {
\r
1644 RowStyle style = new RowStyle ();
\r
1645 TableLayoutRowStyleCollection coll = new TableLayoutPanel ().RowStyles;
\r
1647 TableLayoutRowStyleCollection coll2 = new TableLayoutPanel ().RowStyles;
\r
1648 coll2.Add (style);
\r
1649 Assert.Fail ("#2");
\r
1650 } catch (ArgumentException ex) {
\r
1655 [Test] // Novell bug #497562
\r
1656 public void TestLayoutSettingsSetter ()
\r
1658 using (var tlp = new TableLayoutPanel ()) {
\r
1659 TableLayoutSettings tls;
\r
1661 using (var ms = new MemoryStream ()) {
\r
1662 var formatter = new BinaryFormatter ();
\r
1663 formatter.Serialize (ms, tlp.LayoutSettings);
\r
1667 tls = (TableLayoutSettings) formatter.Deserialize (ms);
\r
1670 tlp.LayoutSettings = tls;
\r
1671 tlp.LayoutSettings = tls; // Should not throw an exception
\r
1676 public void XamarinBug18638 ()
\r
1678 // Spanning items should not have their entire width assigned to the first column in the span.
\r
1679 TableLayoutPanel tlp = new TableLayoutPanel ();
\r
1680 tlp.SuspendLayout ();
\r
1681 tlp.Size = new Size(291, 100);
\r
1682 tlp.AutoSize = true;
\r
1683 tlp.ColumnStyles.Add (new ColumnStyle (SizeType.Absolute, 60));
\r
1684 tlp.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 100));
\r
1685 tlp.ColumnStyles.Add (new ColumnStyle (SizeType.Absolute, 45));
\r
1686 tlp.ColumnCount = 3;
\r
1687 tlp.RowStyles.Add (new RowStyle (SizeType.AutoSize));
\r
1688 var label1 = new Label {AutoSize = true, Text = @"This line spans all three columns in the table!"};
\r
1689 tlp.Controls.Add (label1, 0, 0);
\r
1690 tlp.SetColumnSpan (label1, 3);
\r
1691 tlp.RowStyles.Add (new RowStyle (SizeType.AutoSize));
\r
1693 var label2 = new Label {AutoSize = true, Text = @"This line spans columns two and three."};
\r
1694 tlp.Controls.Add (label2, 1, 1);
\r
1695 tlp.SetColumnSpan (label2, 2);
\r
1697 AddTableRow (tlp, "First Row", "This is a test");
\r
1698 AddTableRow (tlp, "Row 2", "This is another test");
\r
1699 tlp.ResumeLayout ();
\r
1701 var widths = tlp.GetColumnWidths ();
\r
1702 Assert.AreEqual (4, tlp.RowCount, "X18638-1");
\r
1703 Assert.AreEqual (3, tlp.ColumnCount, "X18638-2");
\r
1704 Assert.AreEqual (60, widths[0], "X18638-3");
\r
1705 Assert.Greater (label2.Width, widths[1], "X18638-5");
\r
1706 Assert.AreEqual (45, widths[2], "X18638-4");
\r
1709 private void AddTableRow(TableLayoutPanel tlp, string label, string text)
\r
1711 tlp.SuspendLayout ();
\r
1712 int row = tlp.RowCount;
\r
1713 tlp.RowStyles.Add (new RowStyle (SizeType.AutoSize));
\r
1714 var first = new Label {AutoSize = true, Dock = DockStyle.Fill, Text = label};
\r
1715 tlp.Controls.Add (first, 0, row);
\r
1716 var second = new TextBox {AutoSize = true, Text = text, Dock = DockStyle.Fill, Multiline = true};
\r
1717 tlp.Controls.Add (second, 1, row);
\r
1718 var third = new Button {Text = @"DEL", Dock = DockStyle.Fill};
\r
1719 tlp.Controls.Add (third, 2, row);
\r
1720 tlp.RowCount = row + 1;
\r
1721 tlp.ResumeLayout ();
\r