Foxtable(狐表)用户栏目专家坐堂 → 增加按钮


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

主题:增加按钮

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


加好友 发短信
等级:九尾狐 帖子:2232 积分:15257 威望:0 精华:0 注册:2015/7/18 10:10:00
增加按钮  发帖心情 Post By:2015/10/5 9:32:00 [只看该作者]

我在论坛中学习了别人的一段代码,可以通过双击增加三类控件,即label、line、PictureBox,我也学习一下,在程序中增加了增加button类型的控件,却实现不了我想要的功能,不知道为什么?

Dim ctl As Object
Select Case e.Sender.Gettype.Name
    Case "Label"
        ctl = e.Form.CreateControl("Test" & Format(Date.now,"ddhhmmss"), ControlTypeEnum.Label)
        ctl.Text = "Test" & Format(Date.now,"ddhhmmss")
        ctl.Font = new Font("黑体", 15)
        ctl.autosize = True
   Case "button"
        ctl = e.Form.CreateControl("Test" & Format(Date.now,"ddhhmmss"), ControlTypeEnum.button)
        ctl.Text = "Test" & Format(Date.now,"ddhhmmss")
        ctl.Font = new Font("黑体", 15)
        ctl.autosize = True

 Case "Line"
        ctl = e.Form.CreateControl("Test" & Format(Date.now,"ddhhmmss"), ControlTypeEnum.line)
        ctl.ThickNess = 20
        ctl.LineColor = Color.Red
    Case "PictureBox"
        ctl = e.Form.CreateControl("Test" & Format(Date.now,"ddhhmmss"), ControlTypeEnum.PictureBox)
End Select

If ctl IsNot Nothing Then
    Dim body As object = e.Form.controls("pnl_body")
    ctl.Left = 100
    ctl.Top = 100
    Dim dr As DataRow = DataTables("表A").Find("第一列='" & ctl.Name & "'")
    If dr Is Nothing Then
        Dim r As Row = Tables("表A").AddNew
        r("第一列")=ctl.Name
        r("第二列") = ctl.Left
        r("第三列")=ctl.top
        r("第四列")= e.Sender.Gettype.Name
        r.Save
    End If
    body.AddControl(ctl)
End If


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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/10/7 11:39:00 [只看该作者]

Button没有DoubleClick事件,建议你用一个pictrueBox,放一个图片来模拟按钮,然后判断控件的名字。

 回到顶部