Control.UpdateStyles 方法

定義

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

C#
protected void UpdateStyles ();

範例

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

C#
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();
}

備註

這個方法會 CreateParams 呼叫 方法,以取得要套用的樣式。 指派給 Style 指派給控制項屬性之 CreateParamsExStyle 屬性的 CreateParams 樣式會重新套用。 控制項會重繪,以視需要反映樣式變更。

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

適用於

產品 版本
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
Windows Desktop 3.0, 3.1, 5, 6, 7

另請參閱