fire a click event from another form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello

I have two forms - a start form running in the background and a content form in the foreground. When a timer fires on the start form, I need to fire the click event for a button on the other form. I have delcalered the 2nd form as a friend, but still cannot get to the button's click event

Any help would be very appreciated

thnx
 
Hi

If you are using the Mdiform use the following statements. and note that you need to declare the procedure which is handling the event Click of the button as public

Dim f2 As Form2 = CType(Me.MdiParent.MdiChildren(1), Form2
f2.Button1_Click(f2.Button1, New System.EventArgs()

where button1 is the button placed in the form2

Actually here you are not raising the event, we are indirectly tiggering the event by calling a procedure

If you don't have a MDI form. Have some public module and keep the instance of form2 there and access it in form2 or keep the instance in the form1 itself and access it

I hope this may help you

Sadha Sivam
Malleable Minds Software Pvt Ltd.
India
 
Hi
try this
------------------------------
Dim foo As New Form2
Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
foo.Show()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
'call the button on form 2
foo.ButtonOnForm2.PerformClick()

'call a sub on from2
foo.subOnForm2()
End Sub
-----------------------------------
/jens
eveready said:
Hello,

I have two forms - a start form running in the background and a content
form in the foreground. When a timer fires on the start form, I need to
fire the click event for a button on the other form. I have delcalered the
2nd form as a friend, but still cannot get to the button's click event.
 
Back
Top