求教怎么隐藏datetimepicker框的小图标 如框,这个日历小图标不想让他显示,有没有隐藏的方法,求各位大神指路~~~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 type=>1 2 3 4 5 不要的话是1 其他自己试试 改变dataTimePicker的宽度 继承System.Windows.Forms.DateTimePicker重写部分方法protected override void WndProc(ref System.Windows.Forms.Message m) { base.WndProc(ref m); if (m.Msg == WM_PAINT) { IntPtr hDC = GetWindowDC(m.HWnd); if (hDC.ToInt32() == 0) //如果取设备上下文失败则返回 { return; } PaintDateTimePicker(Graphics.FromHdc(hDC)); ReleaseDC(m.HWnd, hDC); } }private void PaintDateTimePicker(Graphics g) { g.SmoothingMode = SmoothingMode.AntiAlias; g.TextRenderingHint = TextRenderingHint.SystemDefault;//g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; //背景色刷 Brush bkgBrush; //字体色刷 Brush fcBrush; int iDropDownButtonWidth = 17; int iDropDownButtonHeight = this.Height; int iDropDownButtonLocatinX = 17; int iDropDownButtonLocatinY = 0; if (!PublicFunction.IsHigherWinXP()) { iDropDownButtonWidth = 17; iDropDownButtonHeight = this.Height - 2; iDropDownButtonLocatinX = 15; iDropDownButtonLocatinY = 1; } //下拉按钮 Rectangle dropDownRectangle = new Rectangle(ClientRectangle.Width - iDropDownButtonLocatinX, iDropDownButtonLocatinY, iDropDownButtonWidth, iDropDownButtonHeight); //设置背景色和字体色 bkgBrush = new SolidBrush(this._backColor); fcBrush = new SolidBrush(this._foreColor); int iBroderX = 0; int iBroderY = 0; int iBorderWidth = this.Width; int iBorderHeight = this.Height; if (!PublicFunction.IsHigherWinXP()) { iBroderX = -2; iBroderY = -2; iBorderWidth = this.Width + 2; iBorderHeight = this.Height + 2; } //画3D边框 //ControlPaint.DrawBorder3D(g, new Rectangle(iBroderX, iBroderY, iBorderWidth, iBorderHeight), Border3DStyle.SunkenInner, Border3DSide.All); int iBackColorX = 0; int iBackColorY = 0; //为了可以手输,Enable时只是重画按钮区域 if (this.Enabled) { if (PublicFunction.IsHigherWinXP()) { iBackColorX = this.Width - 35; } else { iBackColorX = this.Width - 20; iBackColorY = 1; } } else { if (!PublicFunction.IsHigherWinXP()) { iBackColorX = 2; iBackColorY = 2; } } //画背景 g.FillRectangle(bkgBrush, iBackColorX, iBackColorY, ClientRectangle.Width, ClientRectangle.Height); //为了可以手输,只在Disable时才重画文本 if (!this.Enabled) { int iTextY = this.ClientSize.Height / 2; int iTextX = 0; if (!PublicFunction.IsHigherWinXP()) { iTextY = this.ClientSize.Height / 2 + 3; iTextX = 2; } //画文本 g.DrawString(base.Text, this.Font, fcBrush, iTextX, iTextY, new StringFormat() { LineAlignment = StringAlignment.Center }); } //画边框 //g.DrawRectangle(_BorderPen, new Rectangle(iBroderX, iBroderY, iBorderWidth, iBorderHeight)); ControlPaint.DrawBorder(g, new Rectangle(iBroderX, iBroderY, iBorderWidth, iBorderHeight), borderColor, ButtonBorderStyle.Solid); //画下拉按钮 if (PublicFunction.IsHigherWinXP() || !Application.RenderWithVisualStyles) { ControlPaint.DrawComboButton(g, dropDownRectangle, this.Enabled ? System.Windows.Forms.ButtonState.Flat : System.Windows.Forms.ButtonState.All); } else { ComboBoxRenderer.DrawDropDownButton(g, dropDownRectangle, this.Enabled ? ComboBoxState.Normal : ComboBoxState.Disabled); } g.Dispose(); bkgBrush.Dispose(); fcBrush.Dispose(); } FCKeditor添加图片的时候报错 求一个侧边栏渐隐效果!! 当按下alt键时 menuStrip控件总是响应,如何使menuStrip控件不响应alt键 刚刚学习.Net,到了什么继承,重载,委托这里就搞不明白了? 在C#中怎样编写程序检索文档中是否含有某个关键字! 关于生成和部署的问题? 请问多线程释放问题 批量CSV/TXT文件数据导入数据库对应表,求思路 【求助】Wix打包相关,求前辈指点 C#前景-欢迎讨论 海康威视 预览失败 报错 求助C#WinForm如何直接模拟登录,然后获取网页指定内容,有例子没?
重写部分方法protected override void WndProc(ref System.Windows.Forms.Message m)
{
base.WndProc(ref m); if (m.Msg == WM_PAINT)
{
IntPtr hDC = GetWindowDC(m.HWnd);
if (hDC.ToInt32() == 0) //如果取设备上下文失败则返回
{
return;
} PaintDateTimePicker(Graphics.FromHdc(hDC));
ReleaseDC(m.HWnd, hDC);
}
}
private void PaintDateTimePicker(Graphics g)
{
g.SmoothingMode = SmoothingMode.AntiAlias;
g.TextRenderingHint = TextRenderingHint.SystemDefault;//g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; //背景色刷
Brush bkgBrush; //字体色刷
Brush fcBrush;
int iDropDownButtonWidth = 17;
int iDropDownButtonHeight = this.Height;
int iDropDownButtonLocatinX = 17;
int iDropDownButtonLocatinY = 0; if (!PublicFunction.IsHigherWinXP())
{
iDropDownButtonWidth = 17;
iDropDownButtonHeight = this.Height - 2;
iDropDownButtonLocatinX = 15;
iDropDownButtonLocatinY = 1;
}
//下拉按钮
Rectangle dropDownRectangle = new Rectangle(ClientRectangle.Width - iDropDownButtonLocatinX, iDropDownButtonLocatinY, iDropDownButtonWidth, iDropDownButtonHeight); //设置背景色和字体色 bkgBrush = new SolidBrush(this._backColor);
fcBrush = new SolidBrush(this._foreColor);
int iBroderX = 0;
int iBroderY = 0;
int iBorderWidth = this.Width;
int iBorderHeight = this.Height;
if (!PublicFunction.IsHigherWinXP())
{
iBroderX = -2;
iBroderY = -2;
iBorderWidth = this.Width + 2;
iBorderHeight = this.Height + 2;
} //画3D边框
//ControlPaint.DrawBorder3D(g, new Rectangle(iBroderX, iBroderY, iBorderWidth, iBorderHeight), Border3DStyle.SunkenInner, Border3DSide.All);
int iBackColorX = 0;
int iBackColorY = 0;
//为了可以手输,Enable时只是重画按钮区域
if (this.Enabled)
{
if (PublicFunction.IsHigherWinXP())
{
iBackColorX = this.Width - 35;
}
else
{
iBackColorX = this.Width - 20;
iBackColorY = 1;
}
}
else
{
if (!PublicFunction.IsHigherWinXP())
{
iBackColorX = 2;
iBackColorY = 2;
}
} //画背景
g.FillRectangle(bkgBrush, iBackColorX, iBackColorY, ClientRectangle.Width, ClientRectangle.Height); //为了可以手输,只在Disable时才重画文本
if (!this.Enabled)
{
int iTextY = this.ClientSize.Height / 2;
int iTextX = 0;
if (!PublicFunction.IsHigherWinXP())
{
iTextY = this.ClientSize.Height / 2 + 3;
iTextX = 2;
}
//画文本
g.DrawString(base.Text, this.Font, fcBrush, iTextX, iTextY, new StringFormat() { LineAlignment = StringAlignment.Center });
} //画边框
//g.DrawRectangle(_BorderPen, new Rectangle(iBroderX, iBroderY, iBorderWidth, iBorderHeight));
ControlPaint.DrawBorder(g, new Rectangle(iBroderX, iBroderY, iBorderWidth, iBorderHeight), borderColor, ButtonBorderStyle.Solid); //画下拉按钮
if (PublicFunction.IsHigherWinXP() || !Application.RenderWithVisualStyles)
{
ControlPaint.DrawComboButton(g, dropDownRectangle, this.Enabled ? System.Windows.Forms.ButtonState.Flat : System.Windows.Forms.ButtonState.All);
}
else
{
ComboBoxRenderer.DrawDropDownButton(g, dropDownRectangle, this.Enabled ? ComboBoxState.Normal : ComboBoxState.Disabled);
} g.Dispose();
bkgBrush.Dispose();
fcBrush.Dispose();
}