Windows Form Interaction

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

Guest

I have a parent form and a child form. Both contain a textbox. Child also
has a button.

I want to open child with the following:

Dim mfrmFind As New frmFind
Private Sub OpenForm
AddHandler mfrmFind.Closing, AddressOf frmFindClosing
mfrmFind.TopMost = True
mfrmFind.Show()
End Sub

When I click the button on the child form, I want the text in the child
textbox to be written in the textbox of parent. I can't find a way to do
this. Any ideas?

I want child form to remain open and on top of parent form during this
process.
 
Jan. 12, 2005

What you need to do is pass the instance of the parent form to the
child form. You can do this by modifying the child's constructor. Try:

Public class frmFind
dim frmparent as ParentFormName
public sub new(byref parent as ParentFormName) 'add parameter
frmparent = parent
end sub

'Assumes textbox on parent and child is txtParent and txtChild

private sub Button1_Click(...)
frmparent.txtparent.text = txtchild.text
end sub
end class
-----------------------
Dim mfrmFind As New frmFind(Me) 'Pass instance of parent form
Private Sub OpenForm
AddHandler mfrmFind.Closing, AddressOf frmFindClosing
mfrmFind.TopMost = True
mfrmFind.Show()
End Sub

I hope this makes sense and good night! :)


Joseph MCAD
 
Back
Top