Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Buttons not rendering as XP style

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.

like image 546
tbetts42 Avatar asked Dec 08 '25 12:12

tbetts42


2 Answers

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

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
like image 126
David Avatar answered Dec 10 '25 02:12

David


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

like image 20
Jeff Hall Avatar answered Dec 10 '25 01:12

Jeff Hall