Calling the user defined methods of the form from the user defined control

08-02-2005, 10:41 AM
Hi! I've made my user form (Form1) which has some public method which I've added in. Also I have a user control which I've made myself and which I've added into the toolbox. So a question is: how can I call that some public method of the form from inside of my self-made control? I tried TopLevelControl property. But it displayed the standard control methods only, and mine was out of them. Thanks :D

08-02-2005, 05:54 PM
A usercontrol expects to be placed on an IContainer object.
If you are certain that it will always be placed on a form, then you can get the underlying form by casting the IContainer object to a Form object, because a Form object implements an IContainer.
Dim F As Form = DirectCast(Me.Container, Form)
From there, you can call methods off of the containing form by way of F.

If you made a custom form that you want to call properties from, then you need to cast the Container to the specific form class that you want. :)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum