如何在 Windows 窗体中更改 DateTimePicker 颜色 [英] How to change DateTimePicker Color inWindows Forms

查看:60
本文介绍了如何在 Windows 窗体中更改 DateTimePicker 颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在日历中更改日期,是否可以更改 dateTimePicker 的颜色?

Is it possible to change the color of dateTimePicker if I change date in Calendar?

推荐答案

没有用于更改 Backgroundcolor 更改属性的属性,但是有几个属性允许您自定义日期时间选择器控件.

There is not a property for changing Backgroundcolor change property but There are several properties that allows you to customize the appearance and behavior of the DateTimePicker control.

如果您使用的是 Windows Vista 或 Windows 7 并使用 Aero 等主题,则修改日历颜色的属性不起作用.要查看更改日历颜色的结果,我们需要禁用视觉样式.为了演示,我们将这样做.在解决方案资源管理器中找到 Program.cs 并双击打开它.注释掉或删除该行:

If you are using Windows Vista or Windows 7 and using themes such as Aero, then the properties that modifies the color of the calendar has no effect. To see the results of changing the colors of the calendar, we need to disable Visual Styles. For the sake of demonstration, we will do just that. Find Program.cs in the solution explorer and open it by double clicking it. Comment out or delete the line:

Application.EnableVisualStyles();

有关详细信息,请使用此DateTimePicker 控件

For more information use this The DateTimePicker Control

这篇关于如何在 Windows 窗体中更改 DateTimePicker 颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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