以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  动态生成控件的锚定停靠设置  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=141480)

--  作者:cd_tdh
--  发布时间:2019/9/30 9:47:00
--  动态生成控件的锚定停靠设置

老师,这哪儿不对?

 需要效果:


图片点击可在新窗口打开查看此主题相关图片如下:需要效果.png
图片点击可在新窗口打开查看

 

实际效果:

图片点击可在新窗口打开查看此主题相关图片如下:实际效果.png
图片点击可在新窗口打开查看

 

代码如下:

 

Dim rad1 As WinForm.RadioButton
rad1 = e.Form.CreateControl("RadioButton1",ControlTypeEnum.RadioButton)
rad1.Text = "大图标"
rad1.SetBounds(7,376,80,25)
rad1.Dock= 2 \'锚定
e.Form.Controls("TabControl1").Tabpages(0).AddControl(rad1)

Dim rad2 As WinForm.RadioButton
rad2 = e.Form.CreateControl("RadioButton2",ControlTypeEnum.RadioButton)
rad2.Text = "小图标"
rad2.SetBounds(87,376,80,25)
rad2.Dock= 2 \'锚定
e.Form.Controls("TabControl1").Tabpages(0).AddControl(rad2)

Dim rad3 As WinForm.RadioButton
rad3 = e.Form.CreateControl("RadioButton3",ControlTypeEnum.RadioButton)
rad3.Text = "平铺"
rad3.SetBounds(167,376,80,25)
rad3.Dock= 2 \'锚定
e.Form.Controls("TabControl1").Tabpages(0).AddControl(rad3)

Dim rad4 As WinForm.RadioButton
rad4 = e.Form.CreateControl("RadioButton4",ControlTypeEnum.RadioButton)
rad4.Text = "列表"
rad4.SetBounds(247,376,80,25)
rad4.Dock= 2 \'锚定
e.Form.Controls("TabControl1").Tabpages(0).AddControl(rad4)



--  作者:有点蓝
--  发布时间:2019/9/30 10:04:00
--  

rad1.Dock= 2 这个用法去掉


--  作者:cd_tdh
--  发布时间:2019/9/30 10:19:00
--  

图片点击可在新窗口打开查看此主题相关图片如下:qq图片20190930101812.png
图片点击可在新窗口打开查看

--  作者:有点蓝
--  发布时间:2019/9/30 10:24:00
--  
那是锚定,不是停靠

rad1.Anchor = 什么值合适自己试试,从0开始
--  作者:cd_tdh
--  发布时间:2019/9/30 11:28:00
--  

老师,用代码都不行呢?生成的lvw控件,有上、下、左、右拉伸,麻烦看看。

    Dim lvw0 As WinForm.ListView
    lvw0  = e.Form.CreateControl("ListView1",ControlTypeEnum.ListView)
    lvw0.SetBounds(0,0,704,368)
    \'lvw0.Dock= System.Windows.Forms.DockStyle.top \'停靠
    lvw0.Anchor = system.Windows.Forms.AnchorStyles.Top Or system.Windows.Forms.AnchorStyles.Bottom Or system.Windows.Forms.AnchorStyles.Left Or system.Windows.Forms.AnchorStyles.Right \'锚定
    e.Form.Controls("TabControl1").Tabpages(0).AddControl(lvw0)

    Dim rad1 As WinForm.RadioButton
    rad1 = e.Form.CreateControl("RadioButton1",ControlTypeEnum.RadioButton)
    rad1.Text = "大图标"
    rad1.SetBounds(7,376,80,25)
    rad1.Dock= System.Windows.Forms.DockStyle.bottom \'停靠
    rad1.Anchor = system.Windows.Forms.AnchorStyles.Left Or system.Windows.Forms.AnchorStyles.Bottom \'锚定
    e.Form.Controls("TabControl1").Tabpages(0).AddControl(rad1)

    Dim rad2 As WinForm.RadioButton
    rad2 = e.Form.CreateControl("RadioButton2",ControlTypeEnum.RadioButton)
    rad2.Text = "小图标"
    rad2.SetBounds(87,376,80,25)
    rad2.Dock= System.Windows.Forms.DockStyle.bottom \'停靠
    rad2.Anchor = system.Windows.Forms.AnchorStyles.Left Or system.Windows.Forms.AnchorStyles.Bottom  \'锚定
    e.Form.Controls("TabControl1").Tabpages(0).AddControl(rad2)

    Dim rad3 As WinForm.RadioButton
    rad3 = e.Form.CreateControl("RadioButton3",ControlTypeEnum.RadioButton)
    rad3.Text = "平铺"
    rad3.SetBounds(167,376,80,25)
    rad3.Dock= System.Windows.Forms.DockStyle.bottom \'停靠
    rad3.Anchor = system.Windows.Forms.AnchorStyles.Left Or system.Windows.Forms.AnchorStyles.Bottom \'锚定
    e.Form.Controls("TabControl1").Tabpages(0).AddControl(rad3)

    Dim rad4 As WinForm.RadioButton
    rad4 = e.Form.CreateControl("RadioButton4",ControlTypeEnum.RadioButton)
    rad4.Text = "列表"
    rad4.SetBounds(247,376,80,25)
    rad4.Dock= System.Windows.Forms.DockStyle.bottom \'停靠
    rad4.Anchor = system.Windows.Forms.AnchorStyles.Left Or system.Windows.Forms.AnchorStyles.Bottom \'锚定
    e.Form.Controls("TabControl1").Tabpages(0).AddControl(rad4)

[此贴子已经被作者于2019/9/30 11:29:26编辑过]

--  作者:有点蓝
--  发布时间:2019/9/30 11:30:00
--  
去掉Dock啊
--  作者:cd_tdh
--  发布时间:2019/9/30 11:40:00
--  

去掉也不对。

 



以下内容是专门发给有点蓝浏览


--  作者:有点蓝
--  发布时间:2019/9/30 11:44:00
--  
dim y as integer = e.Form.Controls("TabControl1").height - 30
rad1.SetBounds(7,y,80,25)
--  作者:cd_tdh
--  发布时间:2019/10/23 11:33:00
--  

老师,麻烦看看我动态添加的lvw控件,需要在ListView控件中的RowActivate事件中写以下代码,应该写到哪儿?

Dim r As DataRow  = e.Sender.Current.tag
Dim dr As DataRow = DataTables("用户管理").Find("\',\' + 菜单可用集合 + \',\' like \'%," & r("编号") & ",%\' and 账号=\'" & _username & "\'")
If dr IsNot Nothing Then
    Functions.remove("函数")
    Dim Code As String
    Code = e.sender.current.tag("代码")
    Functions.Add("函数",Code)
    Functions.Complie()
    Functions.Execute("函数")

    \'页签
    Vars("yq") = 1
    Dim t As C1Command.C1DockingTab = Forms("主窗口").Controls("TabControl1").BaseControl
    t.CanCloseTabs = True
    t.CloseBox = 2
    AddHandler t.TabPageClosing, AddressOf _TabPageClosing
Else
    MessageBox.Show("你没有使用权限,请联系管理员!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If

机构:重庆分公司,用户名:chongqing 密码:123456


以下内容是专门发给有点蓝浏览

[此贴子已经被作者于2019/10/23 11:33:04编辑过]

--  作者:有点蓝
--  发布时间:2019/10/23 11:53:00
--  
全局代码

Public Sub ListView1_ItemActivate(sender As Object, e As EventArgs) 

   msgbox(sender.name)

End Sub

绑定事件

AddHandler e.Form.Controls("ListView1").basecontrol.ItemActivate, AddressOf ListView1_ItemActivate