open new form, close existing windows form c#

32
28



If you want to close the form and open new form in windows form c# then must to create a thread for new form. Also open the thread in STA (Single Thread Application) mode.

Nguồn:https://wijstaanvooronzegrondrechten.org/

32 COMMENTS

  1. Is this however a safe way to close the previous form ? What's best practise over here ? Thanks in advance!:)

  2. Hello, Without use "Hide" or Threading cause pb in Memory capatity!!, So easy you can just change your instructions Lines Like:
    frmdoc frmDA = new frmdoc(this) {Text=btnDA.Text};

    frmDA.Show();

    this.Close();
    That's it:)
    Thank you

  3. Do you know how to persist GridView state after closing or restarting windows?. Because, when I close windows, its state is gone.

  4. Thanks .. But there is a small problem .. if i rename the second form to another name like (Main) .. then i should write the code like this : Application.Run(new Forms.Main());

  5. I was struggling with this for a while when I was writing a demo program. Thank you for taking time and giving an example.

LEAVE A REPLY

Please enter your comment!
Please enter your name here