您的位置:首页 > 编程语言 > PHP开发

实现TableLayoutPanel控件的行列拆分的Sub过程

2007-07-27 12:19 495 查看

''' <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

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: