Results 1 to 4 of 4

Thread: Is it possible to reference a control as a property?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2000
    Location
    Peterborough, Cambs, England
    Posts
    176

    Is it possible to reference a control as a property?

    Hi

    I've created a an activex control that control has properties for selecting the images it to use.


    What I would like to do is to have a property for selecting an ImageList from the parent form instead.

    Could someone explain how to add a property that will pass a reference to an image list control?

    Thanks.

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    I wasn't clear on your needs.

    1) You have an ImageList on your user control and you want to give direct access to it to a form?

    2) You have an ImageList on your Form and you want to pass it to your User Control.

    I assumed # 2 and assumed that this is an ActiveX Control project and not a user control in a Standard Exe project (it makes a difference). You must pass controls and forms As Object to Dll's, OCX's etc..

    In your user control try the following code..
    VB Code:
    1. 'user control code
    2. Private mctlImageList As MSComctlLib.ImageList
    3.  
    4. Public Property Set ImageList(ImageListControl As Object)
    5.     If TypeOf ImageListControl Is MSComctlLib.ImageList Then
    6.         Set mctlImageList = ImageListControl
    7.     Else
    8.         Err.Raise -1, , "Expecting an ImageList control, not a " & TypeName(ImageListControl)
    9.     End If
    10. End Property
    11.  
    12. 'Form module
    13. Private Sub Command1_Click()
    14.     Set Me.UserControl11.ImageList = Me.imgPictures
    15. End Sub

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2000
    Location
    Peterborough, Cambs, England
    Posts
    176
    Thanks great. Thanks.


    Is there a way to expose the ImageList property at design time in the property inspecter?

  4. #4
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    I think (but don't know for sure ) that this is a limitation of the User Control. You cannot have objects listed in the properties windows.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width