Windows窗体应用程序-视觉样式? [英] Windows Forms Application - Visual Style?

查看:65
本文介绍了Windows窗体应用程序-视觉样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我会尽量保持简单.

在Windows窗体应用程序中创建的按钮如下所示:

A button created in a Windows Forms Application looks like this:

如果我手动创建表单,则创建的按钮将如下所示:

If I create a form manually, buttons I create will look like this:

我仔细查看了Windows窗体应用程序,发现没有代码可以改变按钮的外观.

I looked thoroughly through the Windows Forms Application and found no code that changes the visual style of buttons.

为什么会发生这种情况?

Is there any simple explanation as to why this is happening?

谢谢.

推荐答案

您将需要调用

You will need to call the EnableVisualStyles method, which is by default called in the Main method of the Program class prior to calling Application.Run (when you create a Windows Forms project, with the auto-generated code).

此方法为应用程序启用视觉样式.视觉风格是形成一个操作系统主题.如果控制和操作系统支持它.为了产生效果,必须先调用 EnableVisualStyles(),然后才能在其中创建任何控件应用程序;通常, EnableVisualStyles()是其中的第一行主要功能.不需要单独的清单即可启用调用 EnableVisualStyles()时的视觉样式.

This method enables visual styles for the application. Visual styles are the colors, fonts, and other visual elements that form an operating system theme. Controls will draw with visual styles if the control and the operating system support it. To have an effect, EnableVisualStyles() must be called before creating any controls in the application; typically, EnableVisualStyles() is the first line in the Main function. A separate manifest is not required to enable visual styles when calling EnableVisualStyles().

这篇关于Windows窗体应用程序-视觉样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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