tags:

views:

418

answers:

3

hey guys, can u please tell me how i can reload a windows form without closing it.thanks

+2  A: 

Put all your initialization code into a method and not the constructor or the Form.Load event and just call that method. This can also include the designer-generated InitializeComponent() method which sets up all controls on the form. You should remove all controls on the form as your first action in that method, though.

Joey
+2  A: 

You cannot do that.

Why do you want to reload a form? Do you want to clear all input controls or something like that? The simplest solution might be to just do the clearing by hand.

Alternatively, you can put all your controls into a user control container. Then just instantiate that user control on your form. If you want to reload your form content, you now just need to remove and re-instantiate the user control.

Konrad Rudolph
A: 

Application.Restart()

Shuts down the application and immediately opens a new instance.

Dan