首页|操作系统|软件开发|网页制作|媒体动画|数据库|ASP教程|ASP.NET教程|PHP教程|JSP教程|XML教程|建站资料|软件学院|行业资讯|平面设计|网络安全|晒IT论坛|IT人才
  位置: 晒IT >> ASP.NET教程 >> Asp.Net实例教程 >> 正文
 
 
可用来显示空值的时间选择控件3
可用来显示空值的时间选择控件3
 
 
public DateInput()

{

// 该调用是 Windows.Forms 窗体设计器所必需的。

InitializeComponent();



tbMonth.ContextMenu = mnu ;

tbYear.ContextMenu = mnu ;

tbDay.ContextMenu = mnu ;

this.Height = 21 ;

this.Value = DateTime.Now ;

this.DateFormat = "yyyy-MM-dd" ;

if (!this.DesignMode)

CreateCalendar() ;

this.UpDown.Width = 16 ;

this.Refresh() ;



}

private void CreateCalendar()

{

Calendar = new MonthCalendar() ;

Calendar.Visible = true ;

Calendar.DateSelected+=new DateRangeEventHandler(Calendar_DateSelected);



frmCalendar = new Form() ;

frmCalendar.FormBorderStyle = FormBorderStyle.None ;

frmCalendar.TopMost = true ;

frmCalendar.Width = 270 ;

frmCalendar.Height = 145 ;

frmCalendar.Controls.Add(Calendar) ;

Calendar.Dock = DockStyle.Fill ;

frmCalendar.StartPosition = FormStartPosition.Manual ;

frmCalendar.Deactivate+=new EventHandler(Calendar_Leave);

frmCalendar.ShowInTaskbar = false ;

}

private void Calendar_DateSelected(object sender, System.Windows.Forms.DateRangeEventArgs e)

{

this.frmCalendar.Hide() ;

this.Value = this.Calendar.SelectionStart ;

this.tbDay.Focus() ;

}

private void Calendar_Leave(object sender, System.EventArgs e)

{

this.frmCalendar.Hide() ;

//this.Value = this.Calendar.SelectionStart ;

this.tbDay.Focus() ;

}

private void RefreshDisplay()

{

bool blGB = false ;

string strChar = "" ;

if (strDateFormat == "yyyy-MM-dd")

strChar = "-" ;

else if (strDateFormat == "yyyy.MM.dd")

strChar = "." ;

else if (strDateFormat == "yyyy/MM/dd")

strChar = "/" ;

else if (strDateFormat== "yyyy年MM月dd日")

blGB = true ;

else

strChar = strFomatChar ;

if (blGB)

{

lbSep1.Text = "年" ;

lbSep2.Text = "月" ;

lbSep3.Text = "日" ;

}

else

{

lbSep1.Text = strChar ;

lbSep2.Text = strChar ;

lbSep3.Text = "" ;

}

this.Refresh() ;

}





/// <summary>

/// 是不是空值

/// </summary>

public bool IsNull()

{

String strYear = tbYear.Text ;

String strMonth = tbMonth.Text ;

String strDay = tbDay.Text ;



if (strYear == "" ||strMonth == "" ||strDay == "" )

return true ;

else

return false ;

}

/// <summary>

/// 设置值为空(实际为时间的最小值)

/// </summary>

public void SetValueNull()

{

this.Value = DateTime.MinValue ;

}



/// <summary>

/// 清空输入值

/// </summary>

private void EmptyInput()

{

tbYear.Text = "" ;

tbMonth.Text = "" ;

tbDay.Text = "" ;

}



private int GetThisMonthMaxDay()

{

int Year = int.Parse(tbYear.Text) ;

int Month = int.Parse(tbMonth.Text) ;



switch(Month)

{

case 2:

if (DateTime.IsLeapYear(Year))//闰年

return 29 ;

else

return 28 ;
[1] [2]  下一页
  • 上一篇: 可用来显示空值的时间选择控件2
  • 下一篇: 可用来显示空值的时间选择控件5
  •  告诉好友  打印此文 关闭窗口 返回顶部
     
    热点文章
     
     
    推荐文章
     
     
    相关文章

    | 设为首页 | 加入收藏 | 联系我们 | 友情链接 | 诚聘英才 |
    Copyright© 2008 ShaiIT.Com .All Rights Reserved
    下载alexa工具,提升您的网站排名