-- 作者:江南小镇
-- 发布时间:2018/2/4 17:21:00
-- [求助]表格布局控件
老师,下面代码怎样修改成最下面剪图的要求。
Dim TblCtl As New Windows.Forms.TableLayoutPanel e.Form.BaseForm.MinimumSize = New Size(510, 298) e.Form.StopRedraw With TblCtl .Name = "TblCtl" .RowCount = 7 .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(490, 268) \'宽 高 .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, 50)) .ColumnStyles.Add(New Windows.Forms.ColumnStyle(Windows.Forms.SizeType.Percent, 80)) .ColumnStyles.Add(New Windows.Forms.ColumnStyle(Windows.Forms.SizeType.Absolute, 50)) .ColumnStyles.Add(New Windows.Forms.ColumnStyle(Windows.Forms.SizeType.Percent, 80)) .ColumnStyles.Add(New Windows.Forms.ColumnStyle(Windows.Forms.SizeType.Absolute, 50)) .ColumnStyles.Add(New Windows.Forms.ColumnStyle(Windows.Forms.SizeType.Percent, 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.Percent, 100)) .RowStyles.Add(New Windows.Forms.RowStyle(Windows.Forms.SizeType.Absolute, 28)) For i As Integer = 0 To 6 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 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 4 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("Label12").BaseControl.Anchor = (System.Windows.Forms.AnchorStyles.none) .Controls.Add(e.Form.Controls("Label12").BaseControl , 2 , 6) .Controls.Add(e.Form.Controls("Txt112").BaseControl , 3 , 6) End With e.Form.Panel.Controls.Add(TblCtl) TblCtl.SetColumnSpan(e.Form.Controls("Txt05").BaseControl,5) e.Form.ResumeRedraw
此主题相关图片如下:图像 1.png
|