简体   繁体   English

更改 datetimepicker 背景颜色 C#

[英]Changing datetimepicker background color C#

I have a datetimepicker in my Windows form.我的 Windows 表单中有一个 datetimepicker。 This may sound like a silly question with a rather simple answer.这听起来像是一个愚蠢的问题,答案相当简单。 However, I just can't find a solution to fit my purpose.但是,我只是找不到适合我目的的解决方案。

Question > Is there a way in which I can change the back colour of the datetimepicker in the form to a different colour other than the generic white?问题 > 有没有办法可以将表单中 datetimepicker 的背面颜色更改为通用白色以外的其他颜色?

Thanks for your help.谢谢你的帮助。

Change the BackColor property更改BackColor属性

Public Class Form1

    Public Sub New()

        InitializeComponent()

        myDateTimePicker1.BackColor = Color.Red

        myDateTimePicker2.BackColor = Color.Yellow

        myDateTimePicker3.BackColor = Color.Green

    End Sub

End Class

or Overrides OnPaint function或覆盖OnPaint function

msdn with more details msdn 详细信息

Set the CalendarMonthBackground property to the color of your choice, but it depends on the theme as well.CalendarMonthBackground属性设置为您选择的颜色,但这也取决于主题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM