Control.UpdateStyles Control.UpdateStyles Control.UpdateStyles Control.UpdateStyles Method

定义

强制将分配的样式重新应用到控件。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. 分配给样式StyleExStyle的属性CreateParams分配给控件的CreateParams属性都将重新应用。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.

UpdateStyles方法不起如果IsHandleCreated属性值是falseThe UpdateStyles method has no effect if the IsHandleCreated property value is false.

适用于

另请参阅