Control.Update Method


使控件重绘其工作区内的无效区域。Causes the control to redraw the invalidated regions within its client area.

 void Update();
public void Update ();
member this.Update : unit -> unit
Public Sub Update ()


执行用于绘制的任何挂起的请求。Executes any pending requests for painting.

可以通过两种方式重绘窗体及其内容:There are two ways to repaint a form and its contents:

  • 可以将 Invalidate 方法的重载之一与 Update 方法一起使用。You can use one of the overloads of the Invalidate method with the Update method.

  • 可以调用 Refresh 方法,该方法强制控件重绘自身及其所有子级。You can call the Refresh method, which forces the control to redraw itself and all its children. 这等效于将 Invalidate 方法设置为 true 并将其与 Update一起使用。This is equivalent to setting the Invalidate method to true and using it with Update.

Invalidate 方法控制绘制或重绘的内容。The Invalidate method governs what gets painted or repainted. Update 方法控制何时发生绘制或重新绘制。The Update method governs when the painting or repainting occurs. 如果使用 Invalidate 并将 Update 方法一起使用而不是调用 Refresh,则将重新绘制的内容取决于你使用 Invalidate 的哪个重载。If you use the Invalidate and Update methods together rather than calling Refresh, what gets repainted depends on which overload of Invalidate you use. Update 方法只是强制立即绘制控件,而 Invalidate 方法控制在调用 Update 方法时绘制的内容。The Update method just forces the control to be painted immediately, but the Invalidate method governs what gets painted when you call the Update method.

有关详细信息,请参阅WM_PAINT主题。For more information, see the WM_PAINT topic.

Applies to

See also