hi all,
iam newbie to c sharp and still trying to learn..iam developing a new windowsapplicattion in csharp and i am trying to open a new form onbtnclickevent and close current form here is my code

form1

private void btnInd_Click(object sender, EventArgs e)
        {
           
            Tab1  dlg = new Tab1(); // assume Form2 is the second form.
           dlg.ShowDialog();
          
            //tabl in new form
        }

and in tab1 onload

private void Tab1_Load(object sender, EventArgs e)
        {
            Form2 f2 = new Form2();
         f2.Close();
            
        }

tab1 formis opening but form2 is not closing

plzhelp
thanks
praveen

try

this.Close();
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.