How to Refresh or Flush the C# Windows Form?
This is my Entry For开发者_开发问答m of my Application.
While Clicking the OK button, It will go to next form for further processing.My Second form is
In the second Form, I have to choose,any one option button and then press ok button.After pressing ok button,i just calling some function and then it will return to Form1.But Form1 has not getting its control for some seconds.It looks like getting collapsed and needs to be refreshed.but i don't know how to refresh a form? Please Guide me to get out of this issue...
It looks like,
Call
this.Invalidate();
or
this.Refresh();
On the Form to update it.
You can redraw the Form by:
Form1.Invalidate();
or
Form1.Refresh();
EDIT:
Some loops and operations on the same thread of Form1
may cause it to stop responding. If it does, you may use the BackgroundWorker
class to avoid it.
Calling the Invalidate method does not force a synchronous paint; to force a synchronous paint, call the Update method after calling the Invalidate method. When this method is called with no parameters, the entire client area is added to the update region.
Control.Invalidate()
And use BeginUpdate() and EndUpdate() if possible.
You can use the Form.Invalidate();
or Form.Refresh();
methods.
精彩评论