' '' <summary> ' '' 拆分TableLayoutPanel ' '' </summary> ' '' <param name="tlp"></param> ' '' <param name="cellCount">拆分后的单元格数,只支持行列数相等的拆分</param> ' '' <remarks>Author:朱二</remarks> Private Sub DrawCell() Sub DrawCell(ByRef tlp As TableLayoutPanel, ByVal cellCount As Integer) Dim columnCount, rowCount As Integer columnCount = Math.Sqrt(cellCount) rowCount = Math.Sqrt(cellCount) '清空子控件,清空行列风格 tlp.Controls.Clear() tlp1.ColumnStyles.Clear() tlp1.RowStyles.Clear() '设置行列数 tlp.ColumnCount = rowCount tlp.RowCount = columnCount '设置行高列宽 Dim i As Integer For i = 1 To columnCount tlp.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, tlp.Width / columnCount)) Next For i = 1 To rowCount tlp.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, tlp.Height / rowCount)) Next End Sub