我用VB开发ActiveX控件,想用ImageList控件保存的图片来设置控件内一些图片属性.
即自定义的ActiveX控件和ImageList控件在同一个容器中(如,在同一个窗体中)当用户在设计窗体时,在我的ActiveX控件中怎样才能通过遍历这个窗体中的所有控件来找到ImageList控件.并用里面的图片设置我的控件中相应的属性。最主要的问题是,我发现UserControl对象只有ContainerHwnd属性,
并没有我想象当中的Container属性,来得到控件所在的容器对象。请问这个问题怎么解决,谢谢!!

解决方案 »

  1.   

    可以通过Parent属性定位到container
      

  2.   

    用UserControl.Parent不知道行不行
      

  3.   

    Dim ctl As Control
    For Each ctl In UserControl.ContainedControls
        MsgBox ctl.Name
    Next
      

  4.   

    用UserControl.Parent获取窗体上的所有控件名称,然后可以用TYPENAME获取是什么控件!
      

  5.   

    可以通过Parent属性定位到container
      

  6.   

    dim frm as form
    set frm = extender.parentdim ctl as control
    for each ctl in frm.controls
      if typeof ctl is image then
        ...
      end if
    next