Link to home
Start Free TrialLog in
Avatar of adam_pedley
adam_pedley

asked on

Reference controls in different class

Hi

I have a form that calls a class. In this class a number of controls are generated and passed back. The controls are then displayed on screen.

One of the controls is a button in which i do an addhandler to a sub in the (control generating) class.

I can press this button and successful run this sub.

But now i need to get a value from other controls when this button is pushed.

I know the names of these other controls but how can i reference them

Thanks
Adam
Avatar of AlexFM
AlexFM

Maybe you need to raise event from the button handler. Form class subscribes to this event and handles it. Since form class knows it's own controls, it can read their values. Control values can be event parameters.
Avatar of adam_pedley

ASKER

but the values of the objects need to get back to the other class somehow
ASKER CERTIFIED SOLUTION
Avatar of AlexFM
AlexFM

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You could try using a control collection
In the class create all your controls then add them to a collection. When you pass the collection to your form all the objects in it will be visible to each other and to your form. You can add the controls from the collection to your form or just use them to reference. Either way the collection object will provide the visibility you require and can be added to dynamicaly. Your event code can be static or dynamic using either addhandler or the event code from the class.