Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to change the border of DateTinePicker control, I have added in windows form.
for eg:- in the same way like when we change the Border Style property of textbox to fixed single then we can see black border to the textbox.
How can i do same in date time picker control ??
Thanks in Advance !!!
Posted
Updated 24-Mar-16 1:22am
Comments
Sergey Alexandrovich Kryukov 28-Feb-12 17:22pm    
Control type name, please. DateTinePicker? I don't know such thing. If it Forms? Tag it. The type name should be full, with the namespace.
--SA

1 solution

To achieve the custom look for the control, you have to override the WndProc method, which is the method that processes all the window messages for this control.

C#
protected override void WndProc(ref Message m)
  {
   IntPtr hDC = GetWindowDC(m.HWnd);
   Graphics gdc = Graphics.FromHdc(hDC);
   switch (m.Msg)
   {
    case WM_NC_PAINT:
     SendMessage(this.Handle, WM_ERASEBKGND, hDC, 0);
     SendPrintClientMsg();
     SendMessage(this.Handle, WM_PAINT, IntPtr.Zero, 0);
     OverrideControlBorder(gdc);

     m.Result = (IntPtr)1; // indicate msg has been processed
     break;
    case WM_PAINT: base.WndProc(ref m);
     OverrideControlBorder(gdc);
     OverrideDropDown(gdc);
     break;
      case  WM_NC_HITTEST:
     base.WndProc(ref m);
     if (DroppedDown)
      this.Invalidate(this.ClientRectangle, false);
     break;
    default:
     base.WndProc(ref m);
     break;
   }
   ReleaseDC(m.HWnd, hDC);
   gdc.Dispose();
  }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900