Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How can I use a string as the name to search controls in an application?

How can I use a string as the name to search controls in an application?

Scheduled Pinned Locked Moved Visual Basic
questionregex
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    econy
    wrote on last edited by
    #1

    The application has about 30 forms, some forms have menubars. All forms and controls are singleton pattern. I want to search all controls in the application to find a control instance with the specific string name, like, "MenuLogin". I tried Me.Controls, but it only contain the controls of the current form. Thanks

    Richard Andrew x64R Richard DeemingR 2 Replies Last reply
    0
    • E econy

      The application has about 30 forms, some forms have menubars. All forms and controls are singleton pattern. I want to search all controls in the application to find a control instance with the specific string name, like, "MenuLogin". I tried Me.Controls, but it only contain the controls of the current form. Thanks

      Richard Andrew x64R Offline
      Richard Andrew x64R Offline
      Richard Andrew x64
      wrote on last edited by
      #2

      You'll have to keep a collection of all Forms in the application, then implement a method on each Form that searches that Form for the control you want.

      The difficult we do right away... ...the impossible takes slightly longer.

      1 Reply Last reply
      0
      • E econy

        The application has about 30 forms, some forms have menubars. All forms and controls are singleton pattern. I want to search all controls in the application to find a control instance with the specific string name, like, "MenuLogin". I tried Me.Controls, but it only contain the controls of the current form. Thanks

        Richard DeemingR Offline
        Richard DeemingR Offline
        Richard Deeming
        wrote on last edited by
        #3

        Assuming the forms you want to search are currently open, then you can use the Application.OpenForms collection[^].


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

        E 1 Reply Last reply
        0
        • Richard DeemingR Richard Deeming

          Assuming the forms you want to search are currently open, then you can use the Application.OpenForms collection[^].


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          E Offline
          E Offline
          econy
          wrote on last edited by
          #4

          Some are opened, some are not

          R 1 Reply Last reply
          0
          • E econy

            Some are opened, some are not

            R Offline
            R Offline
            Ralf Meier
            wrote on last edited by
            #5

            I'm not quiet sure if I understood the question in the right way. I suggest : You iterate through the Application.OpenForms-collection to get the Forms of your Project. This collection return you a Form. Inside each Form you iterate through the Form.Controls-collection and look for your control.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups