Invalidate、Update、Refresh的作用和区别

本文详细解释了控件刷新机制中的关键概念,包括Invalidate、Update及Refresh的区别与联系。Invalidate使控件的特定区域无效并向控件发送绘制消息;Update使控件重绘其工作区内的无效区域,立即调用Paint事件;而Refresh则强制控件及其子控件全部重绘。

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消息。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值