博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C# WinForm窗体 控件Control 的 Invalidate、Update、Refresh的区别
阅读量:6374 次
发布时间:2019-06-23

本文共 1593 字,大约阅读时间需要 5 分钟。

 

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 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: 使控件的特定区域(可以自己设置区域,从而提高性能)无效并向控件发送绘制消息。
                将控件标记为需要重绘,但是不会立即执行刷新重绘,等到系统空闲时进行重绘

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: 使控件重绘其工作区内的无效区域,立即调用Paint事件。若有无效区域,Update将立即触发重绘。
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: 无处不在。如果你调用3次Invalidate,但是系统将只触发一次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.

大多数时候Invalidate已经足够了,当系统要集中进行大量的刷新重绘时,建议使用Invalidate,因为这样系统最终只进行一次刷新,提高了系统性能。如果你想立即执行刷新的时候,建议使用Refresh方法。

转载地址:http://rgjqa.baihongyu.com/

你可能感兴趣的文章
MySql与python交互
查看>>
用Docker下搭建GitLab
查看>>
【转】AlphaGO Zero 原理
查看>>
字符串匹配算法——KMP算法
查看>>
MySQL执行计划的讲解
查看>>
Membership学习(四)-自定义MembershipProvider[xgluxv]
查看>>
(原創) 累 (日記)
查看>>
(轉貼) 比K書更重要的事 (Misc)
查看>>
(原創) 本學期課表 (日記)
查看>>
一些值得深思的话
查看>>
(原創) 如何設定Nios II EDS最佳環境? (SOC) (Nios II)
查看>>
关于Sql Server企业管理器MMC 不能打开文件的解决方法
查看>>
简单验证码识别程序(源码)
查看>>
TCP详解
查看>>
Azure PowerShell (1) PowerShell入门
查看>>
ctl 里面pdef解说
查看>>
如何修改SQL Server 2000身份验证模式和系统管理员
查看>>
Using lnline XAML
查看>>
spring的作用及优势---第一个spring示例
查看>>
Cocos2d-X游戏开发之Windows7+VS2010环境搭建(亲测)
查看>>