我正在尝试构建类似于此的表格布局
---------------------------------------------------------------------
| 01.01.2010 01:00 | 01.01.2010 01:00 | 01.01.2010 01:00 |
---------------------------------------------------------------------
| Some text | More | And | Final text |
| (Multilined) | multilined | more text | Multiple lines,|
| | text | | too |
---------------------------------------------------------------------
它必须动态创建,所以我无法在表单设计器中创建它......
第一种方法如下
// The "outer" table - two rows (the dates and the texts)
TableLayoutPanel table = new TableLayoutPanel();
table.ColumnCount = 1;
table.RowCount = 2;
// Date table - three columns
TableLayoutPanel dateTable = new TableLayoutPanel();
dateTable.ColumnCount = 3;
dateTable.RowCount = 1;
// Text table - four columns
TableLayoutPanel textTable = new TableLayoutPanel();
textTable.ColumnCount = 4;
textTable.RowCount = 1;
// Add it all up and save it to the panel in the winform
table.Controls.Add(dateTable);
table.Controls.Add(textTable);
SomeUIPanel.Controls.Add(table);
它似乎有效,因为我没有例外 - 但它看起来很可怕。表格的宽度太短,文字列没有按照我上面描述的方式添加,我也有感觉,表格的高度太短了,因为一些文字在底部被切断了。
有什么更好的方法吗?或有关这些问题的有用教程?