Wednesday, July 11, 2012

C# open a new form, and close a form...

I tried to close the current form and I start a new form..In this process you can meet following problems


1) this.close()-will close all forms
2) this.hide() -will hide current form..but its opened


I found the way to overcome from this issue..Its really simple..


Write a method like this way



public static void ThreadProc()
{
    Application.Run(new newForm());
}


Then when you click to open a new form,dat button click event like as below

private void button1_Click(object sender, EventArgs e)
{
    System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(ThreadProc));
    t.Start();
}

This worked for me....

Happy coding...No where Like Srilanka...Visit here...meet meeeee

Rajitha Anuradha(Phd In craZy Programming)
rajithasomarathna@gmail.com

C U zoon......

No comments:

Post a Comment