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
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
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.
ASKER
but the values of the objects need to get back to the other class somehow
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.
How about using properties to pass information there and back?
Check out this PAQ: https://www.experts-exchange.com/questions/21469803/Run-a-function-located-on-another-form-from-a-hidden-form.html
And this one might also help: https://www.experts-exchange.com/questions/21524907/Read-properties-from-a-class-from-different-forms.html
Cheers,
Olaf
Check out this PAQ: https://www.experts-exchange.com/questions/21469803/Run-a-function-located-on-another-form-from-a-hidden-form.html
And this one might also help: https://www.experts-exchange.com/questions/21524907/Read-properties-from-a-class-from-different-forms.html
Cheers,
Olaf