Results 1 to 5 of 5

Thread: Help Me...Listing controls in a form with activex control!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Location
    norcross, ga, USA
    Posts
    82

    Question Help Me...Listing controls in a form with activex control!

    I want to enumerate all of the controls on a form containing my activex control and list them in the property page of my control.

    ARRRGGGHHH!!! Can't quite figure it out.

    TIA!

    C

  2. #2
    Frenzied Member jjortiz's Avatar
    Join Date
    Mar 2001
    Location
    NYC
    Posts
    1,768
    If you want to do it from an activex. You have to pass the form and receive type will be form and then do the following.

    me would be the form passed over.
    VB Code:
    1. Dim sControls As Control
    2.     For Each sControls In Me.Controls
    3.         List1.AddItem sControls.Name
    4.     Next

  3. #3
    Frenzied Member jjortiz's Avatar
    Join Date
    Mar 2001
    Location
    NYC
    Posts
    1,768
    Code is really Sloppy but here is the control

    Control:
    VB Code:
    1. Public Function EnumControls(frm As Form) As String()
    2.     Dim sControls As Control
    3.     Dim iControlCount As Integer
    4.     iControlCount = 0
    5.     Dim sArr() As String
    6.    
    7.     For Each sControls In frm.Controls
    8.         ReDim Preserve sArr(iControlCount)
    9.         sArr(iControlCount) = sControls.Name
    10.        
    11.         iControlCount = iControlCount + 1
    12.     Next
    13.    
    14.     EnumControls = sArr
    15. End Function

    Form:
    VB Code:
    1. Private Sub Form_Load()
    2.     Dim sControlArr() As String
    3.    
    4.     sControlArr = UserControl11.EnumControls(Me)
    5.        
    6.     For i = 0 To UBound(sControlArr)
    7.         List1.AddItem sControlArr(i)
    8.     Next
    9. End Sub

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Location
    norcross, ga, USA
    Posts
    82
    Is there anyway the activex control can get the controls names without the form helping (or user)?

    C

  5. #5
    Frenzied Member jjortiz's Avatar
    Join Date
    Mar 2001
    Location
    NYC
    Posts
    1,768
    I do not get when you say the names are you talking about what you are naming them. That is the names of them. If you wan to find out what type they are you have to create a case select and use the TypeOf keyword.

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