Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Backcolor of the textbox of datetimepicker
 

Backcolor of the textbox of datetimepicker

Hi,
I want to change the backcolor of the Datetimepicker's textbox
Datetimepicker.MontheBackgroundCOlor Not works for changing color of the textbox of datetimeker control.

Plz help urgently

Thanks in advance

Hr_Ind  Thursday, February 16, 2006 9:32 AM
Glen Satuito  Saturday, March 24, 2007 3:30 AM

Apparently you cant. From the documentation of the DateTimePicker.BackColor property:


Setting the BackColor has no effect on the appearance of the DateTimePicker. To set the background color for the drop-down calendar of the DateTimePicker, see the CalendarMonthBackground property.

I have no idea why this is the case, but it is.

CommonGenius.com  Saturday, February 18, 2006 4:51 AM
Glen Satuito  Saturday, March 24, 2007 3:30 AM

c# version

[Browsable(true)]

public override Color BackColor

{

get

{

return base.BackColor;

}

set

{

base.BackColor = value;

Invalidate();

}

}

protected override void WndProc(ref Message m)

{

if (m.Msg == 20)

{

Graphics g = Graphics.FromHwnd(m.HWnd);

g.FillRectangle(new SolidBrush(this.BackColor), this.ClientRectangle);

g.Dispose();

return;

}

base.WndProc(ref m);

}

Ruslan Inozemtsev  Wednesday, August 01, 2007 3:17 PM
This doesn't really work at all as the non-transparent calendar control is drawn over top straight away. Is there a way to have an overriden OnPaintBackground called without an overriden OnPaint being called? Overriding OnPaint seems over the top for this, it would be easier to make a new control based on MaskedTextBox and DateTimePicker.
Nick Coleman  Wednesday, August 12, 2009 9:58 AM

You can use google to search for other answers

Custom Search

More Threads

• How to set a DragIcon when a control is dragged and dropped on a designer
• drag drop usercontrol
• ListBox - SelectedItem
• Hiding the Script Combobox in FONT Dialog
• Question about Custom Control on Focus, Cursor
• Web Forms Editor
• JPopupMenu in Windows Forms
• drawing a table in C#
• RightToLeft Property in controls
• I can't add new data source in VC# 2008 design