Getting names of controls

Discussion in 'Questions (Windows Mobile)' started by BjornF, Jan 9, 2008.

  1. BjornF

    BjornF Active Member Licensed User

    Is there an easy way of getting the names of all the controls on a form at once?

    GetControls() only get the names of the controls which have the form as parent, so if you as I use panels to minimize the number of forms then you will need to go through each control and see if they are parents of controls in their turn etc.

    all the best / Björn
  2. Erel

    Erel Administrator Staff Member Licensed User

    First you can use GetControls("") to get all the controls.

    Using the fact that panels controls can't be nested you can use the following code (it will add all controls on Form1 to the ArrayList named al1).
    Sub Globals
    'Declare the global variables here.
        Dim crl(0),tmp(0)
    End Sub

    Sub App_Start
        crl() = GetControls(
    For i = 0 To ArrayLen(crl())-1
    If ControlType(crl(i)) = "Panel" Then
                tmp() = GetControls(crl(i))
    For x = 0 To ArrayLen(tmp())-1
    End If
    'Show the controls
        For i = 0 To al1.Count-1
    End Sub
  3. BjornF

    BjornF Active Member Licensed User

    Thank you Erel. / Björn :)
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice