解决当设置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:下面就可以动态添加控件了…
 
                
            
         
 
         浙公网安备 33010602011771号
浙公网安备 33010602011771号