0
Reply

How To Access a Dynamically Created Control on a Dynamically Created Form

kas baba

kas baba

Jul 16 2009 3:24 PM
2.8k
Hi,

I have an application that dynamically creates winforms.
Dim NewS As New Form
Dim
NewT as new Timer
NewT.Interval = 5000
NewT.enabled = True
NewS.Controls.Add(NewT)
NewS.show

On each winform, I have a Timer.

I have used AddHandler to get Timer.Tick when the interval expires...after which I need to close the calling Form (the form on which the timer resides).

I have been able to access the Timer when it expires..however I need to get a Handle to the form which contains this Timer.
 
'Custom event   
Private Sub Timer_Expired(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim TMR as Timer = CType(sender, Timer)
End
Sub

Any help in this regard would be appreciated !

thanks.