以文本方式查看主题

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

--  作者:yifan3429
--  发布时间:2022/2/9 13:04:00
--  动态控件定位问题
Dim pnl_body As WinForm.panel
pnl_body  = e.Form.CreateControl("pnl", ControlTypeEnum.panel)
pnl_body.Left = 10
pnl_body.Top = 10
e.Form.AddControl(pnl_body)

Dim lbl As WinForm.Button
lbl = e.Form.CreateControl("lable1", ControlTypeEnum.Button)
lbl.Text = "Foxtable"
lbl.Left = 10
lbl.Top = 10
lbl.BackColor = Color.Red
lbl.Image = GetImage("Accept.Ico")
lbl.ImageAlign = ContentAlignment.MiddleLeft
lbl.TextAlign = ContentAlignment.MiddleRight
pnl_body.AddControl(lbl)

Dim lbl2 As WinForm.CheckBox
lbl2 = e.Form.CreateControl("lable1", ControlTypeEnum.CheckBox)
lbl2 .Text = "Foxtable"
lbl2.Left = 90    是否可以基于参考控件间距定位
lbl2 .Top = 10
lbl2 .TextImageRelation = TextImageRelation.ImageAboveText
lbl2.CheckAlign = ContentAlignment.BottomCenter
lbl2 .CheckAlign = ContentAlignment.TopCenter
pnl_body.AddControl(lbl2)

--  作者:有点蓝
--  发布时间:2022/2/9 13:33:00
--  
这个意思?
lbl2.Left = lbl.Left + lbl.Width  +10
--  作者:yifan3429
--  发布时间:2022/2/9 14:19:00
--  
Dim lbl3 As WinForm.TextBox
Dim Values() As Integer = {1,2,3,4,5,6,7,8,9}
For Each nm As String In Values
    lbl3 = e.Form.CreateControl(nm, ControlTypeEnum.TextBox)
    lbl3 .Text = nm
    lbl3.Left = lbl3.Left + lbl3.Width  +5
目前好像是跌在一起,怎么展开。一字排开
    lbl3 .Top = 10
    lbl3.Width = 80
    lbl3.Height = 35
Next
pnl_body.AddControl(lbl3)

--  作者:有点蓝
--  发布时间:2022/2/9 14:47:00
--  
For i as integer = 0 to Values.length - 1
dim nm as string = Values(i)
    lbl3 = e.Form.CreateControl(nm, ControlTypeEnum.TextBox)
    lbl3 .Text = nm
    lbl3.Left = i * (85)  +5

--  作者:yifan3429
--  发布时间:2022/2/9 15:54:00
--  
For i As Integer = 0 To Values.length - 1
    Dim nm As String = Values(i)
    lbl3 = e.Form.CreateControl(nm, ControlTypeEnum.Button)
    lbl3 .Text = nm    
    lbl3.Left = i * (80)  目前是默认的位置。请教第一个起始位置怎么设定
    lbl3.Top = 33
    lbl3.Width = 80
    lbl3.Height = 35
    \'lbl3 .TextImageRelation = TextImageRelation.ImageAboveText
    \'lbl3.TextAlign = ContentAlignment.BottomCenter
    \'lbl3 .CheckAlign = ContentAlignment.TopCenter
    e.Form.Controls("TabControl1").Tabpages(0).AddControl(lbl3)    
Next


--  作者:有点蓝
--  发布时间:2022/2/9 16:07:00
--  
lbl3.Left = i * (80)   + 起始位置
--  作者:yifan3429
--  发布时间:2022/2/9 23:34:00
--  

Dim lb2l As WinForm.Panel
lb2l = e.Form.CreateControl("lable1", ControlTypeEnum.Panel)
lb2l.Left = 2
lb2l.Top = 2
lb2l.Width =  280
lb2l.Height = 250
e.Form.AddControl(lb2l)

lb2l.anchor = Windows.Forms.AnchorStyles.Bottom Or Windows.Forms.AnchorStyles.Right

lb2l.Dock = Windows.Forms.DockStyle.Fill

---------------------------
错误
---------------------------
编译错误:“Forms”不是“Windows”的成员。

 

错误代码:lb2l.Dock = Windows.Forms.DockStyle.Fill
---------------------------
确定  
---------------------------

[此贴子已经被作者于2022/2/9 23:38:03编辑过]

--  作者:有点蓝
--  发布时间:2022/2/10 8:47:00
--  
lb2l.anchor = system.Windows.Forms...........
--  作者:yifan3429
--  发布时间:2022/2/11 16:51:00
--  

Dim lbl As WinForm.Button
lbl = e.Form.CreateControl("lable1", ControlTypeEnum.Button)
\'lbl.Text = ""
lbl.Image = GetImage("Reject16.ico")

lbl.Width = 35
lbl.Height = 35
lbl.FlatStyle = FlatStyle.flat
\'lbl.BackColor = Color.Transparent
lbl.BorderSize = 0
e.Form.AddControl(lbl)
e.Form.Controls("TabControl1").Tabpages(0).AddControl(lbl)
lbl.anchor = system.Windows.Forms.AnchorStyles.Top  Or system.Windows.Forms.AnchorStyles.Left

窗口为一个主窗口,实际大小根据屏幕变化

lbl.Left = 1000
lbl.Top = 10

Button,用上面的方案会是总左上角定位作为起始计算,如何从右上角开始计算。


--  作者:有点蓝
--  发布时间:2022/2/11 17:01:00
--  
比如控件右边距离右上角100

lbl.Left = 父控件的宽度 - 控件的宽度 - 100