'In usercontrol:Public Event ObjectEvent(Info As EventInfo)Private WithEvents o As VBControlExtender Private Sub o_ObjectEvent(Info As EventInfo) RaiseEvent ObjectEvent(Info) End Sub 'In form private sub UserControl1_ObjectEvent(Index as Integer, Info As EventInfo) Select Case Info.Name Case "..." ... End Sub
load则必须在窗体上要有这个控件如果非要满足你的要求,可以另作一个窗体画上这个控件(index=0)
在你加载控件的时候用setparent 把这个控件移到你所需要窗体上来。
你先在设计时添加一个控件control1,并将其 index 设为0,
在程序中用
load control1(1)
这样就行了!
不用时,用unload control1(1).
在UserControl中Controls.Add
但UserControl是数组。
如果是这样的话usercontrol如何映射control的属性方法事件?
可以参考一下这篇文章,在VB中动态添加可响应消息的控件:
http://www.applevb.com/art/dyn_control.txt
Private Sub o_ObjectEvent(Info As EventInfo)
RaiseEvent ObjectEvent(Info)
End Sub
'In form
private sub UserControl1_ObjectEvent(Index as Integer, Info As EventInfo)
Select Case Info.Name
Case "..."
...
End Sub
vbcontrolextender无法表示vb标准控件。