老师,我想把下图的空间摆在页面集合的第一个控件中。
此主题相关图片如下:控件位置.png
下面是原来的代码
Dim TblCtl As New Windows.Forms.TableLayoutPanel
e.Form.BaseForm.MinimumSize = New Size(600, 360)
e.Form.StopRedraw
With TblCtl
.Name = "TblCtl"
.RowCount = 9
.ColumnCount =6
.Anchor = Windows.Forms.AnchorStyles.Left Or _
Windows.Forms.AnchorStyles.Top _
Or Windows.Forms.AnchorStyles.Right _
Or Windows.Forms.AnchorStyles.Bottom
.Location = New Point(10, 15) '左 上
.Size = New Size(552, 288) '宽 高
.BackColor = System.Drawing.Color.Transparent
.CellBorderStyle = Windows.Forms.TableLayoutPanelCellBorderStyle.Single
.Gettype.GetProperty("DoubleBuffered", Reflection.BindingFlags.Instance Or System.Reflection.BindingFlags.NonPublic).SetValue(TblCtl, True, Nothing)
.ColumnStyles.Add(New Windows.Forms.ColumnStyle(Windows.Forms.SizeType.Absolute, 85))
.ColumnStyles.Add(New Windows.Forms.ColumnStyle(Windows.Forms.SizeType.Percent, 80))
.ColumnStyles.Add(New Windows.Forms.ColumnStyle(Windows.Forms.SizeType.Absolute, 90))
.ColumnStyles.Add(New Windows.Forms.ColumnStyle(Windows.Forms.SizeType.Absolute, 112))
.ColumnStyles.Add(New Windows.Forms.ColumnStyle(Windows.Forms.SizeType.Absolute, 60))
.ColumnStyles.Add(New Windows.Forms.ColumnStyle(Windows.Forms.SizeType.Absolute, 80))
.RowStyles.Add(New Windows.Forms.RowStyle(Windows.Forms.SizeType.Absolute, 28))
.RowStyles.Add(New Windows.Forms.RowStyle(Windows.Forms.SizeType.Absolute, 28))
.RowStyles.Add(New Windows.Forms.RowStyle(Windows.Forms.SizeType.Absolute, 28))
.RowStyles.Add(New Windows.Forms.RowStyle(Windows.Forms.SizeType.Absolute, 28))
.RowStyles.Add(New Windows.Forms.RowStyle(Windows.Forms.SizeType.Absolute, 28))
.RowStyles.Add(New Windows.Forms.RowStyle(Windows.Forms.SizeType.Absolute, 28))
.RowStyles.Add(New Windows.Forms.RowStyle(Windows.Forms.SizeType.Absolute, 28))
.RowStyles.Add(New Windows.Forms.RowStyle(Windows.Forms.SizeType.Absolute, 28))
.RowStyles.Add(New Windows.Forms.RowStyle(Windows.Forms.SizeType.Absolute, 28))
.RowStyles.Add(New Windows.Forms.RowStyle(Windows.Forms.SizeType.Absolute, 28))
For i As Integer = 0 To 9
e.Form.Controls("Label0" & i).BaseControl.Anchor = (System.Windows.Forms.AnchorStyles.none) '居中
.Controls.Add(e.Form.Controls("Label0" & i).BaseControl , 0 , i)
.Controls.Add(e.Form.Controls("Txt0" & i).BaseControl , 1 , i)
Next
'For i As Integer = 0 To 1
'e.Form.Controls("Label0" & i).BaseControl.Anchor = (System.Windows.Forms.AnchorStyles.none) '居中
' .Controls.Add(e.Form.Controls("Panel0"& i).BaseControl , 1 , i)
' Next
For i As Integer = 0 To 4
e.Form.Controls("Label" & i).BaseControl.Anchor = (System.Windows.Forms.AnchorStyles.none)
.Controls.Add(e.Form.Controls("Label" & i).BaseControl , 2 , i)
.Controls.Add(e.Form.Controls("Txt1" & i).BaseControl , 3 , i)
Next
For i As Integer = 0 To 2
e.Form.Controls("Labe21" & i).BaseControl.Anchor = (System.Windows.Forms.AnchorStyles.none)
.Controls.Add(e.Form.Controls("Labe21" & i).BaseControl ,4 , i)
.Controls.Add(e.Form.Controls("Txt21" & i).BaseControl , 5 , i)
Next
e.Form.Controls("Label13").BaseControl.Anchor = (System.Windows.Forms.AnchorStyles.none)
e.Form.Controls("Label12").BaseControl.Anchor = (System.Windows.Forms.AnchorStyles.none)
.Controls.Add(e.Form.Controls("Label12").BaseControl , 2 , 5)
.Controls.Add(e.Form.Controls("Txt112").BaseControl , 3 , 5)
.Controls.Add(e.Form.Controls("Label13").BaseControl , 2 , 6)
.Controls.Add(e.Form.Controls("Txt113").BaseControl , 3 , 6)
'.Controls.Add(e.Form.Controls("Panel01").BaseControl , 2 , 5)
End With
e.Form.Panel.Controls.Add(TblCtl)
TblCtl.SetColumnSpan(e.Form.Controls("Txt09").BaseControl,5)
'TblCtl.SetColumnSpan(e.Form.Controls("Txt06").BaseControl,3)
TblCtl.SetColumnSpan(e.Form.Controls("Txt14").BaseControl,2)
TblCtl.SetColumnSpan(e.Form.Controls("Txt13").BaseControl,2)
TblCtl.SetColumnSpan(e.Form.Controls("Txt112").BaseControl,2)
TblCtl.SetColumnSpan(e.Form.Controls("Txt113").BaseControl,2)
'TblCtl.SetColumnSpan(e.Form.Controls("Panel01").BaseControl,3)
'TblCtl.SetRowSpan(e.Form.Controls("Panel01").BaseControl, 4)
e.Form.ResumeRedraw