tags:

views:

145

answers:

3

I have a .net WinForms app with buttons that are displaying as XP style (rounded corners) at design time, but Windows 2000 style (square corners) at runtime. My desktop theme is set to XP style. I'm guessing there's an obvious setting that I'm overlooking. Thanks.

+5  A: 

In your Program.Main() method make sure you have these 2 lines before Application.Run:

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
David
+2  A: 
static void Main() 
{
    Application.EnableVisualStyles();
    Application.Run(new Form1());
}

EnableVisualStyles must be called before creating any controls in the application; typically, EnableVisualStyles is the first line in the Main function.

MSDN Reference

Jeff Hall
+1  A: 

There's also an option in project properties called Enable XP Visual Styles that does the same trick... Actualy if you put the code above, this checkbox will become check in the project properties...

Fox
Nice tip, although I found that it only applies to VB projects.
Jeff Hall
Oh well... I tought it was a general properties for projects... The only language where I sometime used this option is VB, with C# I never had to do this to get the XP Style... Weird...
Fox