Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

Control.UpdateStyles Method

Forces the assigned styles to be reapplied to the control.

[Visual Basic]
Protected Sub UpdateStyles()
[C#]
protected void UpdateStyles();
[C++]
protected: void UpdateStyles();
[JScript]
protected function UpdateStyles();

Remarks

This method calls the CreateParams method to get the styles to apply. The styles assigned to the Style and ExStyle properties of the CreateParams object assigned to the control's CreateParams property are reapplied. The control is repainted to reflect the style changes if necessary.

The UpdateStyles method has no effect if the IsHandleCreated property value is false.

Example

[Visual Basic, C#, C++] The following example enables double-buffering on a Form and updates the styles to reflect the changes.

[Visual Basic] 
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

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

[C++] 
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();
   }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Control Class | Control Members | System.Windows.Forms Namespace | CreateParams

Show:
© 2015 Microsoft