以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  GroupBox 动态控件  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=190751)

--  作者:yifan3429
--  发布时间:2024/3/1 20:40:00
--  GroupBox 动态控件
Dim GBox As WinForm.GroupBox
Dim Value As String = "新增明细|新增报价|新增楼层|新增区域"
Dim sps() As Char = {"|"}
Dim Names() As String = Value.Split(sps)
Dim s As Integer = 2
Dim t As Integer = 5
For i As Integer = 0 To Names.length - 1
    If i <> 0 Then
        If i Mod 1 = 0 Then
            s = 2
            t = t + 200.5 \'高度换算
        Else
            s = s + 261.5 \'宽度换算
        End If
    End If 
    Dim nm As String = Names(i)
    GBox = e.Form.CreateControl(nm, ControlTypeEnum.GroupBox)
    GBox.Theme = "(none)" \'去掉原来的样式
    \'    zcdd.Font = New Font("宋体", 13, FontStyle.Bold)
    GBox.Text = nm
    GBox.name = nm
    GBox.Width = 261
    GBox.Height = 200
    GBox.BackColor = Color.FromARGB(255, 255, 224)
    GBox.ForeColor = Color.FromARGB(169, 169, 169)
    GBox.Left = s + 8
    GBox.Top = t + 2 
    e.Form.AddControl(GBox) 
Next



Dim zcdd As WinForm.Button
\'If dr("窗口按键_菜单") < > Nothing Then
\'    Dim Value As String = dr("窗口按键_菜单")
\'    Dim sps() As Char = {"|"}
\'    Dim Names() As String = Value.Split(sps)
\'Dim s As Integer = 2
\'Dim t As Integer = 5
For i As Integer = 0 To Names.length - 1
    If i <> 0 Then
        If i Mod 3 = 0 Then
            s = 2
            t = t + 50
        Else
            s = s + 66.5
        End If
    End If
    Dim nm As String = Names(i)
    zcdd = e.Form.CreateControl(nm, ControlTypeEnum.Button)
    zcdd.Theme = "(none)" \'去掉原来的样式
    zcdd.Font = New Font("宋体", 9, FontStyle.Bold)
    zcdd.Text = nm
    zcdd.name = nm
    zcdd.Width = 65
    zcdd.Height = 49
    zcdd.Left = s + 8
    zcdd.Top = t + 2 
    zcdd.BorderSize = 0
    zcdd.BackMost = False
    \'        Forms("主窗_菜单").Controls("菜单页面").Tabpages("功能操作").AddControl(zcdd)   
    \'    e.Form.AddControl(zcdd)
    e.Form.Controls("新增明细").AddControl(zcdd)    不能嵌入控件找不到更多的属性
Next

--  作者:有点蓝
--  发布时间:2024/3/2 9:52:00
--  
首先一个窗口里的控件名称不能有重复,GroupBox已经使用同样的名称创建过一轮了

其次按钮的位置已经超出了GroupBox的范围
    zcdd.Left = s + 8
    zcdd.Top = t + 2
    MsgBox(zcdd.Left & "," & zcdd.top)

--  作者:yifan3429
--  发布时间:2024/3/2 13:09:00
--  
e.Form.panel.parent.parent.Width = 270 \'设定窗口的宽度
e.Form.Text = CurrentTable.Name & "_ 菜单"
\'Dim CheckBox1 As WinForm.GroupBox
Dim GBox As WinForm.GroupBox
Dim Value As String = "新增明细|新增报价|新增楼层|新增区域"
Dim sps() As Char = {"|"}
Dim Names() As String = Value.Split(sps)
Dim s As Integer = 2
Dim t As Integer = 5
For i As Integer = 0 To Names.length - 1
    If i <> 0 Then
        If i Mod 1 = 0 Then
            s = 2
            t = t + 200.5 \'高度换算
        Else
            s = s + 261.5 \'宽度换算
        End If
    End If 
    Dim nm As String = Names(i)
    GBox = e.Form.CreateControl(nm, ControlTypeEnum.GroupBox)
    GBox.Theme = "(none)" \'去掉原来的样式
    \'    zcdd.Font = New Font("宋体", 13, FontStyle.Bold)
    GBox.Text = nm
    GBox.name = nm
    GBox.Width = 261
    GBox.Height = 200
    GBox.BackColor = Color.Transparent \'透明背景色  
    GBox.ForeColor = Color.FromARGB(255, 255, 255) 
    GBox.Left = s + 8
    GBox.Top = t + 2 
    e.Form.AddControl(GBox) 
Next



Dim zcdd As WinForm.Button
\'If dr("窗口按键_菜单") < > Nothing Then
Dim Value1 As String = "新增明|新增报|新增楼|新增区"
\'    Dim sps() As Char = {"|"}
Dim Names1() As String = Value1.Split(sps)
\'Dim s As Integer = 2
\'Dim t As Integer = 5
For i As Integer = 0 To Names1.length - 1
    If i <> 0 Then
        If i Mod 3 = 0 Then
            s = 2
            t = t + 50
        Else
            s = s + 66.5
        End If
    End If
    Dim nm As String = Names1(i)
    zcdd = e.Form.CreateControl(nm, ControlTypeEnum.Button)
    zcdd.Theme = "(none)" \'去掉原来的样式
    zcdd.Font = New Font("宋体", 9, FontStyle.Bold)
    zcdd.Text = nm
    zcdd.name = nm & 1
    zcdd.Width = 65
    zcdd.Height = 49
    zcdd.Left = s + 8
    zcdd.Top = t + 2 
    zcdd.BorderSize = 0
    zcdd.BackMost = False
    \'        Forms("主窗_菜单").Controls("菜单页面").Tabpages("功能操作").AddControl(zcdd)   
    \'    e.Form.AddControl(zcdd)
    e.Form.Controls("新增明细").AddControl(zcdd) 
Next

改了也是不行

--  作者:有点蓝
--  发布时间:2024/3/2 13:50:00
--  
按钮的位置已经超出了GroupBox的范围
    zcdd.Left = s + 8
    zcdd.Top = t + 2
    MsgBox(zcdd.Left & "," & zcdd.top)

--  作者:有点蓝
--  发布时间:2024/3/2 13:53:00
--  
处理按钮前把t、s的值还原为初始值。或者改为使用不同的变量计算