Welcome to WindowsClient.net | Sign in | Join

Here are some frequently asked questions about Windows Forms and their answers.

Windows Forms FAQs

How do I get EnableVisualStyles method to support XP styles in an application?

Microsoft has confirmed that calling the Application.EnableVisualStyles method (in the System.Windows.Forms namespace) in the Main method resulting in some ImageList corruption is a bug. This workaround appears to solve the problem.

public virtual void Main()
{ 
  Application.EnableVisualStyles(); 
  // Calling DoEvents after the above method call seems to fix this issue
  Application.DoEvents(); 
  Application.Run( new Form1() ); 
} 

George Shepherd, Syncfusion, and Martin Robins



Page view counter