以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 控件全局代码 求助 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=115154) |
-- 作者:yifan3429 -- 发布时间:2018/3/1 21:00:00 -- 控件全局代码 求助 Dim tab As WinForm.TabControl = e.Form.Controls("TabControl1") Dim Name As String = e.Sender.Text \'获取按钮名称 If tab.TabPages(name) Is Nothing Then tab.TabPages.Add(name,name) Dim pb = tab.BaseControl Forms(Name).OPEN(-1000,-1500) Forms(Name).BaseForm.TopLevel = False Forms(Name).BaseForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None Forms(Name).BaseForm.Dock = System.Windows.Forms.DockStyle.Fill PB.TabPages(name).Controls.Clear PB.TabPages(name).Controls.add(Forms(Name).BaseForm) End If tab.SelectedPage = tab.TabPages(name) 下面每个按键的代码都一样 怎么简化不用每个按键输入代码 [此贴子已经被作者于2018/3/1 20:59:54编辑过]
|
-- 作者:有点甜 -- 发布时间:2018/3/1 21:58:00 -- 按钮名称改成规则的,如 btn_窗口_01 、 btn_窗口_02 这样,然后改代码
If e.sender.name.startswith("btn_窗口_") Then
Dim tab As WinForm.TabControl = e.Form.Controls("TabControl1") Dim Name As String = e.Sender.Text \'获取按钮名称 If tab.TabPages(name) Is Nothing Then tab.TabPages.Add(name,name) Dim pb = tab.BaseControl Forms(Name).OPEN(-1000,-1500) Forms(Name).BaseForm.TopLevel = False Forms(Name).BaseForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None Forms(Name).BaseForm.Dock = System.Windows.Forms.DockStyle.Fill PB.TabPages(name).Controls.Clear PB.TabPages(name).Controls.add(Forms(Name).BaseForm) End If tab.SelectedPage = tab.TabPages(name) End If |
-- 作者:yifan3429 -- 发布时间:2018/3/1 22:14:00 -- 放在哪呢 |
-- 作者:有点甜 -- 发布时间:2018/3/1 22:33:00 -- click事件 |