Pasing a string to a textbox

Hello All,
I have a small issue with passing a string to a textbox.. the senario is as follow:

Form1 is opened with textbox1 and button1

When pressing button1, form2 opens to allow searching in a database.

Results of form2 search are listed in listview1.

selecting the required reslt is by clicking the desired item in listview1.

Now.. I need to pass the result to textbox1 in form1 that is already opened.

How?

[447 byte] By [Fayed] at [2007-12-16]
# 1
Hi,

use a property to manipulate the text in form1. and pass form1 in the construcor of form2.

rgerbig at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic Language...
# 2
Hi,
In your form1, you could create a method to set the text in your textbox:

Public Sub setText(newText as String)
text1.Text = newText
End Sub

Just call this function in the event of you listbox this way.

'Inside the click event of listview
Dim myForm As Form1 = DirectCast(Me.Owner, Form1)
myForm.setText(listview.Text <Or whatever the result is>)
' end snippet

BTW, in showing your form2, you must ust the form2.Show(this) method so that the owner would be set to form1...
cheers,
Paul June A. Domag

PaulDomag at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic Language...
# 3
Paul,
Thank you it worked with a tiny modificartion. I had to declare form2 as owned by form1 while opening form2

Dim fv as New Form2
fv.Owner=me
fv.show()

Thanks again

Fayed at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic Language...