How can I use a string as the name to search controls in an application?
-
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
-
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
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.
-
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
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
-
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
-
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.