.NET开发

本类阅读TOP10

·NHibernate快速指南(翻译)
·vs.net 2005中文版下载地址收藏
·【小技巧】一个判断session是否过期的小技巧
·VB/ASP 调用 SQL Server 的存储过程
·?dos下编译.net程序找不到csc.exe文件
·通过Web Services上传和下载文件
·学习笔记(补)《.NET框架程序设计(修订版)》--目录
·VB.NET实现DirectDraw9 (2) 动画
·VB.NET实现DirectDraw9 (1) 托管的DDraw
·建站框架规范书之——文件命名

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
可用来显示空值的时间选择控件2

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

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




相关文章

相关软件