/ Forums / Advansys Formativ / Creating Solutions with Formativ / Get Type of Control on Designed Form

  • Creator
    Topic
  • #4421
    ctaleck
    Participant

      I would like to be able to get the Type of the control in code for a designed form. Is this possible?

      Something similar to what you can do with a “fcControlDlg”:

      ‘ works for a fcContolDlg
      Set Dlg = Utilities.NewControlBoxDialog
      ‘ define dialog properties here
      Set EditControl = Dlg.AddEditControl
      ‘define control properties here
      Set CL = Dlg.ControlList
      For i = 0 To CL.Count – 1
      Utilities.Trace i & ” ” & CL.Item(i).Caption & “=” & CL.Item(i).ControlType
      Next

      ‘ non-working attempt for a Designed Form
      For i = 0 To TestForm.ComponentCount-1
      Set thisComponent = TestForm.Components(i)
      Utilities.Trace i & ” = ” & thisComponent.Caption & “=” & thisComponent.ControlType ‘ <- Does not work
      Next

      I’ve also tried to iterate through “TestForm.Controls” instead of “TestForm.Components.”

    • Author
      Replies
    • #8135
      Support 1
      Participant

        Thanks for your question.

        You can use the following sample code to enumerate the Components and Controls arrays on a form. Note that a Component may also be a Control.

          Utilities.Trace "MainForm.ComponentCount = " & MainForm.ComponentCount
          for I = 0 to MainForm.ComponentCount - 1
            Utilities.Trace I & " = " & MainForm.Components(I).ClassName
          next
        
          Utilities.Trace "MainForm.ControlCount = " & MainForm.ControlCount
          for I = 0 to MainForm.ControlCount - 1
            Utilities.Trace I & " = " & MainForm.Controls(I).ClassName
          next

        I hope this helps you.

        Regards,
        Advansys Support

      Viewing 1 replies (of 1 total)
      • You must be logged in to reply to this topic.