窗口的AfterLoad事件中,如下代码,动态增加控件:
Dim lbl0 As WinForm.Label
lbl0 = e.Form.CreateControl("lable0", ControlTypeEnum.Label)
lbl0.Text = "起始日期"
lbl0.Left = 0
lbl0.Top = 55
e.Form.Controls("Panel2").AddControl(lbl0)
Dim lbl1 As WinForm.Label
lbl1 = e.Form.CreateControl("lable1", ControlTypeEnum.Label)
lbl1.Text = "产品名称"
lbl1.Left = 0
lbl1.Top = 105
e.Form.Controls("Panel2").AddControl(lbl1)
Dim txt0 As WinForm.TextBox
txt0 = e.Form.CreateControl("TextBox1", ControlTypeEnum.TextBox)
txt0.Left = 50
txt0.Top = 50
e.Form.Controls("Panel2").AddControl(txt0)
Dim txt1 As WinForm.TextBox
txt1 = e.Form.CreateControl("TextBox2", ControlTypeEnum.TextBox)
txt1.Left = 50
txt1.Top = 100
e.Form.Controls("Panel2").AddControl(txt1)
作为开发者,随时可以改变代码,动态增加不同的控件,改变控件布局。
现在需要,将不同的代码输出、保存到文本文件。
在项目发布后,让最终用户选择(当然,不会允许编辑)执行不同的代码,从而生成不同的控件,或改变控件布局。
各位大虾、小蟹,请指教。