Windows Forms 表单看起来不是原生的 [英] Windows Forms form doesn't look native

查看:29
本文介绍了Windows Forms 表单看起来不是原生的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经向 VB.net 应用程序添加了一个 Windows 窗体表单,并以通常的方式显示它:

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()

问题是该表单在显示时具有非常丑陋的windows 95"样式.基本上系统主题(在我的例子中是 Windows 10)没有得到应用.结果如下图所示:

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:

正如你所看到的,它不仅看起来丑陋和非原生,而且布局也搞砸了:注意 TextBox 溢出输入"GroupBox并且Fine"Button 没有填充垂直空间.请注意,该表单在 Visual Studio 设计器中看起来非常好,具有原生外观!但是启动时,表单没有主题,看起来像截图.

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.

有什么线索吗?附加信息:运行 Windows 10 x64视觉工作室 2015针对 .NET 4.0 编译的应用程序

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

推荐答案

您需要调用 Application.EnableVisualStyles().

You need to call Application.EnableVisualStyles().

这篇关于Windows Forms 表单看起来不是原生的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆