Okay, got it to work, but it's a bit of work.
First, uber thanks to Claudio Ganahl who actually made the working C# code (My C is getting really rusty). Second, if someone could translate the C# code to VB, that would rock. ATM, I don't have the time to beat on it more.
So, start up a fresh copy of Visual Studio .Net. Create a C# class library project. Call it "DateTimePicker2" or something along those lines.
In the class file, paste the following:
Code:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace DateTimePicker2
{
public class DateTimePicker2 : DateTimePicker
{
private Color _BackColor = SystemColors.Window;
public override Color BackColor
{
get
{
return _BackColor;
}
set
{
_BackColor = value;
Invalidate();
}
}
protected override void WndProc(ref Message m)
{
if (m.Msg == (int) 0x0014 /* WM_ERASEBKGND */)
{
Graphics g = Graphics.FromHdc(m.WParam);
g.FillRectangle(new SolidBrush(_BackColor),
ClientRectangle);
g.Dispose();
return;
}
base.WndProc(ref m);
}
}
}
you'll get a bunch of unknown type errors. We need to add the references. The cheap way is to add a windows form to the project, and then delete it.
Build the project. Copy the DateTimePicker2.dll file that is created and copy it to your application's directory.
In your application, add a .Net reference to the DateTimePicker2.dll. Add a DateTimePicker to your form. go into the windows generated code and change the System.Windows.Form.DateTimePicker reference to DateTimePicker2.DateTimePicker2. There are 2 of these (one for declaring, the other for instantiating).
Voalia! A date time picker w/ back color.
-Rick
----------------------