Forums - C# Corner

Forum guidelines
ullas K

ullas K

  • 0
  • 0
  • 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)

Startup Conference 2016

SPONSORED BY

Custom Software Development
MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.