Anjumnagpal
Member
- Joined
- Feb 4, 2009
- Messages
- 15
- Programming Experience
- Beginner
I have a windows applications.
Form 2 is child form of Form1 . Basically when button on form2 (child form) is clicked, it raise an events, which writes something in testbox on form1 (parent form). This is my code
parent form form1 code:
Public Class Form1
Public mycount As Integer
Private WithEvents obj As New Form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim newdoc As Form2
mycount = mycount + 1
newdoc = New Form2()
newdoc.Text = "Doc" + Str(mycount)
newdoc.MdiParent = Me.Parent
newdoc.Show()
End Sub
Private Sub obj_textfill(ByVal txt As String) Handles obj.textfill
TextBox1.Text = txt
End Sub
End Class
form2 child form code:
Public Class Form2
Public Event textfill(ByVal txt As String)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
RaiseEvent textfill("hi")
End Sub
End Class
This is the first time I am tring to use events.. I am not sure what's going wrong.. the textfill event is never called from form1. Please help
Form 2 is child form of Form1 . Basically when button on form2 (child form) is clicked, it raise an events, which writes something in testbox on form1 (parent form). This is my code
parent form form1 code:
Public Class Form1
Public mycount As Integer
Private WithEvents obj As New Form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim newdoc As Form2
mycount = mycount + 1
newdoc = New Form2()
newdoc.Text = "Doc" + Str(mycount)
newdoc.MdiParent = Me.Parent
newdoc.Show()
End Sub
Private Sub obj_textfill(ByVal txt As String) Handles obj.textfill
TextBox1.Text = txt
End Sub
End Class
form2 child form code:
Public Class Form2
Public Event textfill(ByVal txt As String)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
RaiseEvent textfill("hi")
End Sub
End Class
This is the first time I am tring to use events.. I am not sure what's going wrong.. the textfill event is never called from form1. Please help