TableLayoutPanel does not show up C#

本文关键字:up show not does TableLayoutPanel | 更新日期: 2023-09-27 18:37:07

我想以编程方式创建一个表格布局面板。我有如下代码:

        TableLayoutPanel tlpCurrent = new TableLayoutPanel();
        tlpCurrent.RowStyles.Clear();
        tlpCurrent.RowCount++;
        tlpCurrent.RowStyles.Add(new RowStyle(SizeType.Absolute, 40f));
        tlpCurrent.RowCount++;
        tlpCurrent.RowStyles.Add(new RowStyle(SizeType.Absolute, 40f));
        tlpCurrent.RowCount++;
        tlpCurrent.RowStyles.Add(new RowStyle(SizeType.Absolute, 40f));
        tlpCurrent.RowCount++;
        tlpCurrent.RowStyles.Add(new RowStyle(SizeType.Absolute, 40f));
        tlpCurrent.RowCount++;
        tlpCurrent.RowStyles.Add(new RowStyle(SizeType.Absolute, 40f));
        tlpCurrent.RowCount++;
        tlpCurrent.RowStyles.Add(new RowStyle(SizeType.Absolute, 40f));
        tlpCurrent.RowCount++;
        tlpCurrent.RowStyles.Add(new RowStyle(SizeType.Absolute, 40f));
        tlpCurrent.RowCount++;
        tlpCurrent.RowStyles.Add(new RowStyle(SizeType.Absolute, 40f));
        tlpCurrent.ColumnStyles.Clear();
        tlpCurrent.ColumnCount++;
        tlpCurrent.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 150f));
        for (int i = 0; i < 3; i++)
        {
            tlpCurrent.ColumnCount++;
            tlpCurrent.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 150f));
        }
        tlpCurrent.Location = new Point(500, 100);
        tlpCurrent.Size = new System.Drawing.Size(300, 300);
        tlpCurrent.AutoSize = true;
        this.Controls.Add(tlpCurrent);

但我在窗口窗体上看不到它。我相信这段代码运行没有任何错误。有什么想法吗?

TableLayoutPanel does not show up C#

要使边框可见,您可以使用:

tlpCurrent.CellBorderStyle= TableLayoutPanelCellBorderStyle.Single;