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. 指派給 Style 的樣式和指派給控制項 CreateParams 屬性 CreateParamsExStyle 屬性會重新套用。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 屬性值為 falseUpdateStyles 方法不會有任何作用。The UpdateStyles method has no effect if the IsHandleCreated property value is false.

適用於

另請參閱