Control.UpdateStyles 方法

定义

强制将分配的样式重新应用到控件。Forces the assigned styles to be reapplied to the control.

protected:
 void UpdateStyles();
protected void UpdateStyles ();
member this.UpdateStyles : unit -> unit
Protected Sub UpdateStyles ()

示例

下面的代码示例对 Form 启用双缓冲,并更新样式以反映所做的更改。The following code example enables double-buffering on a Form and updates the styles to reflect the changes.

public:
   void EnableDoubleBuffering()
   {
      // Set the value of the double-buffering style bits to true.
      this->SetStyle( static_cast<ControlStyles>(ControlStyles::DoubleBuffer | ControlStyles::UserPaint | ControlStyles::AllPaintingInWmPaint), true );
      this->UpdateStyles();
   }
public void EnableDoubleBuffering()
{
   // Set the value of the double-buffering style bits to true.
   this.SetStyle(ControlStyles.DoubleBuffer | 
      ControlStyles.UserPaint | 
      ControlStyles.AllPaintingInWmPaint,
      true);
   this.UpdateStyles();
}
Public Sub EnableDoubleBuffering()
   ' Set the value of the double-buffering style bits to true.
   Me.SetStyle(ControlStyles.DoubleBuffer _
     Or ControlStyles.UserPaint _
     Or ControlStyles.AllPaintingInWmPaint, _
     True)
   Me.UpdateStyles()
End Sub

注解

此方法调用 CreateParams 方法来获取要应用的样式。This method calls the CreateParams method to get the styles to apply. 重新应用分配给控件的 CreateParams 属性的 CreateParamsStyleExStyle 属性的样式。The styles assigned to the Style and ExStyle properties of the CreateParams assigned to the control's CreateParams property are reapplied. 如有必要,将重新绘制控件以反映样式更改。The control is repainted to reflect the style changes if necessary.

如果 IsHandleCreated 属性值 false,则 UpdateStyles 方法不起作用。The UpdateStyles method has no effect if the IsHandleCreated property value is false.

适用于

另请参阅