1

I've added a Windows Forms form to a VB.net application, and I'm showing it with the usual:

Dim form As New FormInsCapiLettore()
form.ShowDialog()

The problem is that the form, when shown, has an incredibly ugly "windows 95" style. Basically the system theme (Windows 10 in my case) does not get applied. The result is in the screenshot below:

enter image description here

As you can see, not only does it look ugly and non-native, but the layout also screws up: notice the TextBox spilling outside the "input" GroupBox and the "Fine" Button not filling the vertical space. Notice that the form looks absolutely fine in the Visual Studio designer, with the native look! But when launched, the form has no theme and looks like the screenshot.

Any clues? Additional info: Running Windows 10 x64 Visual Studio 2015 Application compiled against .NET 4.0

Reza Aghaei
  • 120,393
  • 18
  • 203
  • 398
Master_T
  • 7,232
  • 11
  • 72
  • 144
  • 1
    Hmm, no, that's what the Win10 theme looks like. Clearly visible from the frame buttons at the upper right and the 1-pixel window border. It is the Visual Studio designer that cannot properly render a form with the Win10 visual style, you see the Win7 frame style. That's a hard limitation in the visual style renderer. Making your app dpiAware is pretty important these days. – Hans Passant Feb 04 '16 at 17:55
  • Sorry, but I've developer many WinForms and WPF apps and the windows 10 theme does NOT look like that. Look at the button! Buttons on Win10 do not look like that, they have a darker shade, flatter look and border. – Master_T Feb 04 '16 at 17:58
  • Firstly, they enabled customizing the title bar color in one of the latest updates. Secondly, I'm talking about the CONTENTS of the windows, not the border. SLaks's answer is the correct one, in fact here's how it looks now. Notice how the UI elements are very different: http://imgur.com/7ovfkLp – Master_T Feb 04 '16 at 18:19

1 Answers1

8

You need to call Application.EnableVisualStyles().

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964