中国IT动力,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档 | 网通镜像
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 程序开发 > 编程语言 > .NET > 临时文章
可用来显示空值的时间选择控件2
作者:未知 时间:2005-01-11 12:12 出处:Blog 责编:chinaitpower
              摘要:暂无

using System;

using System.Collections;

using System.ComponentModel;

using System.Drawing;

using System.Data;

using System.Windows.Forms;

 

namespace XPangLib

{

     /// <summary>

     /// DateInput 的摘要说明。

     /// </summary>

     public class DateInput : System.Windows.Forms.UserControl

     {

          #region 成员控件

 

          private System.Windows.Forms.MonthCalendar Calendar ;

          private System.Windows.Forms.Form frmCalendar ;

          private System.Windows.Forms.Panel panel3;

          private System.Windows.Forms.Button btnMain;

          private System.Windows.Forms.VScrollBar UpDown;

          private System.Windows.Forms.Panel panel1;

          private System.Windows.Forms.Panel panel2;

          private System.Windows.Forms.Label lbSep3;

          private System.Windows.Forms.TextBox tbDay;

          private System.Windows.Forms.Label lbSep2;

          private System.Windows.Forms.TextBox tbMonth;

          private System.Windows.Forms.Label lbSep1;

          private System.Windows.Forms.TextBox tbYear;

          private System.Windows.Forms.Label label2;

          private System.Windows.Forms.Label lbSpace;

          #endregion

 

         /// <summary>

         /// 必需的设计器变量。

         /// </summary>

          private System.ComponentModel.Container components = null;

 

          private ContextMenu mnu = new ContextMenu() ;

        

          #region 自定义属性

          [Browsable(true),ReadOnly(false)]

         public Size Size

         {

              set

              {

                   base.Size = new Size(value.Width,21) ;                

                   this.SetBounds(base.Location.X,base.Location.Y,this.Width,base.Height) ;

                   this.Refresh() ;

              }

              get

              {                  

                   return base.Size ;

              }

         }

        

          private string strDateFormat ;        

          [CategoryAttribute("显示属性和值"),

          TypeConverterAttribute(typeof(DateFormatConverter)),

          DescriptionAttribute("时间显示格式"),

          ReadOnlyAttribute(false)]

         public string DateFormat

         {

              get

              {

                   return strDateFormat ;

              }

              set

              {

                   strDateFormat = value ;

                   RefreshDisplay() ;

              }

         }

        

 

          private string strFomatChar ;

          [CategoryAttribute("显示属性和值"),

          DescriptionAttribute("自定义显示格式"),

          ReadOnlyAttribute(false)]

         public string FomatChar

         {

              get

              {

                       return strFomatChar ;

               }

              set

              {

                   strFomatChar = value ;

                   RefreshDisplay() ;

              }

         }

    

 

         bool blShowUpDown = false ;

                  

          [CategoryAttribute("显示属性和值"),

          DescriptionAttribute("显示UpDown按钮"),

          ReadOnlyAttribute(false)]

         public bool ShowUpDown

         {

              get

              {

                   return blShowUpDown ;

              }

              set

              {

                   blShowUpDown = value ;

                   this.btnMain.Visible = !value ;

                   this.UpDown.Visible = value ;

              }

         }

    

        

          private DateTime dtValue ;

         /// <summary>

         /// 选定的日期

         /// </summary>

          [CategoryAttribute("显示属性和值"),

          DescriptionAttribute("选定的值"),

          ReadOnlyAttribute(false)]

         public DateTime Value

         {

              get

              {

                   if (IsNull())

                        dtValue = DateTime.MinValue ;

                   else

                   {

                       string strYear = tbYear.Text ;

                       string strMonth = tbMonth.Text ;

                       string strDay = tbDay.Text ;

                       string strDate = strYear +"-"+ strMonth +"-" +strDay ;

                        dtValue = DateTime.Parse(strDate) ;

                   }

                   return dtValue ;

              }

              set

              {

                   dtValue = value ;

                   if (dtValue == DateTime.MinValue)

                        EmptyInput() ;

                   else

                   {

                        tbYear.Text = dtValue.Year.ToString() ;

                        tbMonth.Text = dtValue.Month.ToString() ;

                        tbDay.Text = dtValue.Day.ToString() ;

                   }

                   this.Refresh() ;

              }

         }

          #endregion

关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 chinaitpower.com All rights reserved. www.chinaitpower.com 版权所有