Control.Refresh - does an Control.Invalidate followed by Control.Update.
Refresh: 強(qiáng)制控件使其工作區(qū)無效并立即重繪自己和任何子控件。==Invalidate + Update Control.Invalidate - invalidates a specific region of the Control (defaults to entire client area) and causes a paint message to be sent to the control.Invalidate marks the control (region, or rect) as in need of repainting, but doesn't immediately repaint (the repaint is triggered when everything else has been taken care of and the app becomes idle).
Invalidate: 使控件的特定區(qū)域(可以自己設(shè)置區(qū)域,從而提高性能)無效并向控件發(fā)送繪制消息。 將控件標(biāo)記為需要重繪,但是不會立即執(zhí)行刷新重繪,等到系統(tǒng)空閑時進(jìn)行重繪。 Control.Update - causes the Paint event to occur immediately (Windows will normally wait until there are no other messages for the window to process, before raising the Paint event).Update causes the control to immediately repaint if any portions have been invalidated. Update: 使控件重繪其工作區(qū)內(nèi)的無效區(qū)域,立即調(diào)用Paint事件。若有無效區(qū)域,Update將立即觸發(fā)重繪。 The paint event of course is where all the drawing of your form occurs. Note there is only one pending Paint event, if you call Invalidate 3 times, you will still only receive one Paint event.
Paint: 無處不在。如果你調(diào)用3次Invalidate,但是系統(tǒng)將只觸發(fā)一次Paint事件。 Most of the time Invalidate is sufficient, and advisable as you can do a bunch of invalidations (either explicit or implicit) and then let the control repaint itself when the app is idle. It is advisable to use Update or Refresh when you want the control to immediately repaint because the app will not be idle for a user-noticable period of time.
大多數(shù)時候Invalidate已經(jīng)足夠了,當(dāng)系統(tǒng)要集中進(jìn)行大量的刷新重繪時,建議使用Invalidate,因?yàn)檫@樣系統(tǒng)最終只進(jìn)行一次刷新,提高了系統(tǒng)性能。如果你想立即執(zhí)行刷新的時候,建議使用Refresh方法。
本文來自CSDN博客,轉(zhuǎn)載請標(biāo)明出處:http://blog.csdn.net/ZHENNIUBILE/archive/2010/07/22/5754980.aspx |
|