Question : Windows form dialog box Refresh parent

Hi,
I have a Textbox which displays values using DataReader on form1.
when user clicks a  button a dialog form (form2 opens up). User enters value in textbox and clicks button.
I save the value into Database and close the form. I want the form1  Textbox control to refresh to show the value inserted. How can i achieve this.

Answer : Windows form dialog box Refresh parent

Hmm... here is the actual problem , you are always trying to acceess the previous page(Form1) using following code

form1 _frm1  = new form1(Student_ID);

but the above line of code actually creating new Form1 object and passing Student_ID to it's constructor , not previous forms object(form - from where you called second form i.e Form2).


do...

create one public property in form2 to store studentID , like...

private string _studentId;
public string StudentID
{
      get { return this._studentId; }
}

and set studentID after insert the record from form2...


and just call StudentID in form1 like...

Form2 frmSecond = new Form2();
frmSecond.ShowDialog();  
this.textBox1.Text = frmSecond.StudentID;


Random Solutions  
 
programming4us programming4us