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.

適用於

另請參閱