我得textbox的默认值为DateTime.Now.tostring(),要求用户更改后的类型也为上述类型,谢谢!

解决方案 »

  1.   

    ^(\d|[01]\d|2[0-3]):(\d|[0-5]\d):(\d|[0-5]\d)$
      

  2.   

    srz007(呵呵) :
    我默认的类型为:2004-10-9 13:44:25 不仅仅是日期,我没找到既有日期又有时间的控件
      

  3.   

    http://www.regexlib.com/Search.aspx?k=Date
      

  4.   

    在验证事件中加入以下代吗:private void textBox1_Validating(object sender, System.ComponentModel.CancelEventArgs e)
    {
        try
        {
    DateTime dt = DateTime.Parse( this.textBox1.Text );
        }
        catch
        {
    MessageBox.Show( this, "日期格式错误!请重新输入。", "格式错误", MessageBoxButtons.OK, MessageBoxIcon.Exclamation );
    e.Cancel = true;
        }
    }
      

  5.   

    textbox.Text就是string啊莫非你是要 typeof(System.DateTime.Now) == typeof(myNow)
      

  6.   

    为何这样不行呢?
    System.Text.RegularExpressions.Regex zip=new Regex(@"^(19[0-9]{2}|[2-9][0-9]{3})-((0(1|3|5|7|8)|10|12)-(0[1-9]|1[
    0-9]|2[0-9]|3[0-1])|(0(4|6|9)|11)-(0[1-9]|1[0-9]|2[0-9]|30)|
    (02)-(0[1-9]|1[0-9]|2[0-9]))\x20(0[0-9]|1[0-9]|2[0-3])(:[0-5
    ][0-9]){2}$
    ");
    if(zip.IsMatch(kaishishijian.Text.ToString()))
    {
    Response.Redirect("www.sohu.com");
    }