开发者

How to Refresh or Flush the C# Windows Form?

开发者 https://www.devze.com 2023-04-03 17:37 出处:网络
This is my Entry For开发者_开发问答m of my Application. While Clicking the OK button, It will go to next form for further

This is my Entry For开发者_开发问答m of my Application.

How to Refresh or Flush the C# Windows Form?

While Clicking the OK button, It will go to next form for further processing.My Second form is

How to Refresh or Flush the C# Windows Form?

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,

How to Refresh or Flush the C# Windows Form?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号