4
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by xanawa
1

According to MSDN :

Setting the BackColor has no effect on the appearance of the DateTimePicker.

You need to write a custom control that extends DateTimePicker. Override the BackColor property and the WndProc method.

Whenever you change the BackColor, don't forget to call the myDTPicker.Invalidate() method. This will force the control to redrawn using the new color specified.

const int WM_ERASEBKGND = 0x14;
protected override void WndProc(ref System.Windows.Forms.Message m)
{
     if(m.Msg == WM_ERASEBKGND)
     {
       Graphics g = Graphics.FromHdc(m.WParam);
       g.FillRectangle(new SolidBrush(_backColor), ClientRectangle);
       g.Dispose();
       return;
     }

     base.WndProc(ref m);
}

Here is another example of chnaging backColor to dtp: http://www.codeproject.com/KB/selection/DateTimePicker_With_BackC.aspx

Edited by Mitja Bonca: n/a

0

In addition to Mitja Bonca

dateTimePicker1.CalendarForeColor = Color.Red;// will change the fore color of the calender in the datetimepicker, 
 dateTimePicker1.CalendarTitleForeColor=Color.Red; // will change the color of title

Edited by abelLazm: n/a

0

I have Windows 7 and i tried these before posting here
dateTimePicker1.CalendarForeColor = Color.Red;// will change the fore color of the calender in the datetimepicker, dateTimePicker1.CalendarTitleForeColor=Color.Red; // will change the color of titledateTimePicker1.CalendarForeColor = Color.Red;// will change the fore color of the calender in the datetimepicker,
dateTimePicker1.CalendarTitleForeColor=Color.Red; // will change the color of title

but still didn't work now i will try like the other guy told me

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.