Since you are using ShowDialog(), the form will show up modally and you wont
be able to edit the calling form (Form1). You will have to use Show() only.
As for saving the text of a textbox on form2, you can do that in the Click
event of the OK button in form2. Since your SaveText method is in Form1, you
can pass a reference to Form1 into Form2 and make SaveText as a friend
method. Here's how you could do it (there are other ways too):
' All this in Form2
Private frmForm1 As Form1
' Constructor of Form2
Public Sub New(ByVal frmCalling As Form1)
frmForm1 = frmCalling
End Sub
' OK Button Click in Form2
Private Sub btnOK_Click(ByVal sender as Object, _
ByVal e As EventArgs) Handles btnOK.Click
frmForm1.SaveText(Me.txtInput.Text)
End Sub
' In Form1
Dim f As New Form2(Me)
f.Show()
That should pretty much do what you are looking for.
hope that helps..
Imran.
"Mika M" <mika.mahonen@nospam_kolumbus.fi> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi!
If Windows Form -application has for example a button on Form1 which
Click-event opens other Form2-form like...
Dim f as New Form2
f.ShowDialog()
If (f.DialogResult = DialogResult.OK) Then
SaveText(f.txtInput.Text)
End If
f.Dispose()
...and when OK-button was pressed on Form2, it saves content of the
TextBox on the Form2 before closing Form2.
This is working fine like this way for now. But I want to keep Form1 as an
editable form when Form2 is open, how to this?
I tried simply changing line f.ShowDialog() to f.Show(), but then code
execution is going to the end of the Sub, and I can't catch when OK was
pressed on the Form2. I thing this is simple question. Hopefully you
understand what I'm trying to explain :)
--
Thanks in advance!
Mika