''' <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 
本文介绍如何在VB.NET中编写一个Sub过程,用于动态地拆分TableLayoutPanel控件的行列,以便自定义布局。内容涵盖具体的代码实现和步骤,帮助开发者更好地理解和操作Windows Forms应用中的TableLayoutPanel。
3万+

被折叠的 条评论
为什么被折叠?



