本文介绍了使用c#更改Datetimepicker控件的边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想更改DateTinePicker控件的边框,我在windows窗体中添加了。
例如: - 就像我们将文本框的Border Style属性更改为固定单一时一样,我们可以看到文本框的黑色边框。
我怎么能在日期时间选择器控件中做同样的事情??
在此先感谢!!!
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 !!!
推荐答案
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();
}
这篇关于使用c#更改Datetimepicker控件的边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!