以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]控件位置  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=114547)

--  作者:江南小镇
--  发布时间:2018/2/9 8:46:00
--  [求助]控件位置

老师,我想把下图的空间摆在页面集合的第一个控件中。


此主题相关图片如下:控件位置.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


--  作者:有点甜
--  发布时间:2018/2/9 8:50:00
--  

e.Form.Panel.Controls.Add(TblCtl)

 

改成

 

Dim tab = e.form.controls("TabControl1").BaseControl

tab.tabpages(1).controls.add(TblCtl)


--  作者:y2287958
--  发布时间:2018/2/9 10:41:00
--  
佩服折腾,虽然觉得这样折腾性价比不高。
--  作者:江南小镇
--  发布时间:2018/2/9 11:34:00
--  
老师,我修改不了恳请老师帮忙。
--  作者:有点甜
--  发布时间:2018/2/9 11:37:00
--  
以下是引用江南小镇在2018/2/9 11:34:00的发言:
老师,我修改不了恳请老师帮忙。

 

1、你怎么改的?报什么错?

 

2、实例发上来测试。


--  作者:江南小镇
--  发布时间:2018/2/9 11:50:00
--  
以下是引用江南小镇在2018/2/9 8:46:00的发言:

老师,我想把下图的空间摆在页面集合的第一个控件中。


此主题相关图片如下:控件位置.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

Dim TblCtl As Windows.Forms.TableLayoutPanel = e.Form.Panel.Controls("TblCtl")
e.Form.Panel.Controls.Remove(TblCtl)
TblCtl.Dispose

 

 

 

老师,就上面两组代码。


--  作者:有点甜
--  发布时间:2018/2/9 11:57:00
--  

e.Form.Panel.Controls.Add(TblCtl)

 

改成

 

Dim tab = e.form.controls("TabControl1").BaseControl

tab.tabpages(1).controls.add(TblCtl)

 

有什么问题,如果有问题,上传实例。


--  作者:江南小镇
--  发布时间:2018/2/9 12:12:00
--  
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:表格.table


--  作者:有点甜
--  发布时间:2018/2/9 12:17:00
--  
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:表格.table


--  作者:江南小镇
--  发布时间:2018/2/9 15:09:00
--  
谢谢老师,那我要在多个页面集合中添加控件怎么拢。
[此贴子已经被作者于2018/2/9 15:16:42编辑过]