gpt4 book ai didi

c# - WinForms - 无边界 DateTimePicker

转载 作者:太空宇宙 更新时间:2023-11-03 15:07:09 25 4
gpt4 key购买 nike

我有一个看起来像这样的股票 winform datetimepicker... winform datetimepicker

我想让它看起来像这样......

winform datetimepicker modified

WinForm TextBox 有一个无边框选项,我手动创建了一条水平线来产生无缝下划线 TextBox 的错觉,但是 DateTimePicker 好像没有borderless选项。

我可以做些什么来使 DateTimePicker 看起来像上面的示例,或者至少删除边框以便我可以手动放置下划线?

最佳答案

要实现控件的自定义外观,您必须覆盖 WndProc 方法,该方法处理此控件的所有窗口消息。

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# - WinForms - 无边界 DateTimePicker,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42859084/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com