Invalidate、Update、Refresh的作用和区别

来源:互联网 发布:淘宝货款什么时候到账 编辑:程序博客网 时间:2024/06/18 13:32

Control.Refresh - does an Control.Invalidate followed by Control.Update.
Refresh:强制控件使其工作区无效并立即重绘自己和任何子控件。==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: 使控件的特定区域(可以自己设置区域,从而提高性能)无效并向控件发送绘制消息。

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:使控件重绘其工作区内的无效区域。 立即调用Paint事件。

invalidate:使控件的指定区域无效,有相关重载方法,通常使用情况不多。

update:使控件无效区域进行重绘。一般体现在数据加载等耗时操作过程中。

refresh:使控件区域无效,并重绘控件区域。一般体现在动态加载控件的时候,强制无效并重绘。

Application.DoEvents:交出CPU控制权,让系统可以处理队列中的所有Windows消息。