如框,这个日历小图标不想让他显示,有没有隐藏的方法,求各位大神指路~~~

解决方案 »

  1.   

    type=>1 2 3 4 5 不要的话是1  其他自己试试
      

  2.   

    改变dataTimePicker的宽度
      

  3.   

    继承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();
            }