解决当设置TableLayoutPanel属性AutoSize = true and Dock = fill,最后一行和列出现空白。

    问题:当设置TableLayoutPanel属性AutoSize = true and Dock = fill,

             动态向其单元格添加控件时,最后一行和列会出现空白的现象。

       设置行为自适应:

        for (int row = 0; row < rowCount; row++)
        {
            table.RowStyles.Add(new RowStyle(SizeType.AutoSize));
        }

        添加一为了修复Bug 

        table.RowStyles.Add(new RowStyle(SizeType.Absolute, 0.0F));
        table.RowCount = rowCount + 1;

        设置列为自适应

          for (int col = 0; col < colCount; col++)
          {
                table.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
          }

           添加一为了修复Bug

           table.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 0.0F));
           table.ColumnCount = colCount + 1;

       OK:下面就可以动态添加控件了…

posted on 2011-01-16 22:30  Proxima  阅读(2754)  评论(0编辑  收藏  举报

导航