-- 作者:kaituozhe
-- 发布时间: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
|