Can anyone tell me how to reference methods of new instance of an object?

For example i have a usercontrol with a couple of text boxes. The class for this control has a method that validates if the text boxes are empty and if so opens a message box or returns the values of these boxes.

A new instance of this usercontrol is being created on a windows form at runtime and docked into a container panel. The idea is that i can use a button on the form which calls the validation method which this control has in its class. However because the object has not been instansiated until runtime i am unable to reference its methods in the form.cs. I know i could drag and drop the usercontrol onto the form but i may wish to have multiple controls on this form.

The reason for doing is to eventualy create multiple pages (usercontrols) on one windows form. I realise i could use tab control but its ugly and i havent learnt how to use ownerdraw....yet!

Thanks in advance

5 Years
Discussion Span
Last Post by thines01

1) put the object higher in scope
2) make the methods static and have them validate objects of the same type.
3) make a helper class that does nothing but the validation.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.