以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 动态控件定位问题 (http://foxtable.com/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.anchor = Windows.Forms.AnchorStyles.Bottom Or Windows.Forms.AnchorStyles.Right lb2l.Dock = Windows.Forms.DockStyle.Fill ---------------------------
错误代码: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.Left = 1000 Button,用上面的方案会是总左上角定位作为起始计算,如何从右上角开始计算。 |
-- 作者:有点蓝 -- 发布时间:2022/2/11 17:01:00 -- 比如控件右边距离右上角100 lbl.Left = 父控件的宽度 - 控件的宽度 - 100
|