Control.UpdateStyles 方法

定義

強制重新套用指派的樣式至控制項。

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

範例

下列程式碼範例會在 上 Form 啟用雙緩衝處理,並更新樣式以反映變更。

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 呼叫 方法,以取得要套用的樣式。 指派給 Style 指派給控制項屬性之 CreateParamsExStyle 屬性的 CreateParams 樣式會重新套用。 控制項會重繪,以視需要反映樣式變更。

如果 IsHandleCreated 屬性值為 false ,則 UpdateStyles 方法沒有任何作用。

適用於

另請參閱