ullas K

ullas K

  • NA
  • 55
  • 0

Closing one form while keeping other form open

Dec 2 2012 4:21 AM
Hi,
    I have a Main Form which is the parent form.I open Form1 inside the parent form and Form1 has a textbox textbox1.On textbox1_textchanged event i should open Form2 and  pass a value to it keeping Form1 opened.Depending upon that value the datagridview on Form2 gets populated.Up to here it is fine.Now what i need is when i leave the Textbox1(ie,textbox1_leave event) i should close the Form2.How can i acheive that

My code for Textchanged event in Form1 is

private void textBox1_TextChanged(object sender, EventArgs e)
        {
            bookname = textBox1.Text;
            Form2 obj = new Form2();
            obj.Show();
            textBox1.Focus();
 
        }

Thanks in advance

Answers (13)