tablelayoutpanel的C#winform autoscroll不起作用

时间:2018-06-08 19:42:04

标签: c# winforms tabular autoscroll

我正在尝试构建一个可自动滚动的表格,我从这个示例中获取灵感:Add Row Dynamically in TableLayoutPanel

我已经设置了autoscroll tr​​ue并且我为我的情况仅创建了3个静态列,但是autoscroll不起作用。

我的代码示例:

        panel.ColumnCount = 0;
        panel.RowCount = 0;

        panel.RowStyles.Add(new RowStyle(SizeType.Absolute, 30F));
        panel.Controls.Add(new Label() { Text = "           Address" }, 0, 0);
        panel.Controls.Add(new Label() { Text = "           Contact No" }, 1, 0);
        panel.Controls.Add(new Label() { Text = "           Email ID" }, 2, 0);



        for (int i = 0; i <= 8; i++)
        {
            // For Add New Row (Loop this code for add multiple rows)
            panel.RowCount = panel.RowCount + 1;
            panel.RowStyles.Add(new RowStyle(SizeType.Absolute, 50F));
            panel.Controls.Add(new Label() { Text = "Street, City, State" }, 0, panel.RowCount - 1);
            panel.Controls.Add(new Label() { Text = "888888888888" }, 1, panel.RowCount - 1);
            panel.Controls.Add(new Label() { Text = "xxxxxxx@gmail.com" }, 2, panel.RowCount - 1);
        }

        panel.AutoScroll = true;

Table

Properties

1 个答案:

答案 0 :(得分:0)

我解决了!我设置了以下选项:

感谢kaj帮助我!