Foxtable(狐表)用户栏目专家坐堂 → 动态控件定位问题


  共有4624人关注过本帖树形打印复制链接

主题:动态控件定位问题

帅哥哟,离线,有人找我吗?
yifan3429
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:九尾狐 帖子:2482 积分:22932 威望:0 精华:0 注册:2011/3/29 17:14:00
动态控件定位问题  发帖心情 Post By: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)

 回到顶部
帅哥哟,离线,有人找我吗?
yifan3429
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:九尾狐 帖子:2482 积分:22932 威望:0 精华:0 注册:2011/3/29 17:14:00
  发帖心情 Post By: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)

 回到顶部
帅哥哟,离线,有人找我吗?
yifan3429
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:九尾狐 帖子:2482 积分:22932 威望:0 精华:0 注册:2011/3/29 17:14:00
  发帖心情 Post By: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


 回到顶部
帅哥哟,离线,有人找我吗?
yifan3429
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:九尾狐 帖子:2482 积分:22932 威望:0 精华:0 注册:2011/3/29 17:14:00
  发帖心情 Post By: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编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
yifan3429
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:九尾狐 帖子:2482 积分:22932 威望:0 精华:0 注册:2011/3/29 17:14:00
  发帖心情 Post By: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,用上面的方案会是总左上角定位作为起始计算,如何从右上角开始计算。


 回到顶部