I have a form form1 and there is a search button for searching the doctor when i click search button then a new form opens i.e. form2 and in form2 there is a data grid view control and i want when i select any doctor and click on apply button then this doctor id and name comes onto the form1 textbox1 and textbox2.

This is for using C# window application and i am using sql database.

:yawn:To keep it simple open your second form i.e. Form2 as modal window and while closing the form you can easily access its value to Form1...
While clicking on apply retreive your required data into a public variable
Try This:

//Fomm2 Code:
//on Click event of apply button

public string DocName="Tester";//Your retreived value it will be
Close();
Form2 frm2=new Form2();
frm2.ShowDialog()
TextBox1.Text=frm2.DocName

Hope this will work....

if your doctor name and id and public strings, ints then you can get them on form2 by writing something like

form1.'yourstringname'

lol - what a help :)
check your pm.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.