要在TextBox输入时间格式 1995-05-01,只要求输入数字就行了,- 自动获取,如何实现。
 如何在TextBox中加入时间格式( ____-__-__ )  ????

解决方案 »

  1.   

    用TextChanged事件,判断长度是否达到4个,不到则只允许输入数字,达到则自动加入-,其它处理同理。
      

  2.   

    DateTimePicker dtp = new DateTimePicker();
    dtp.CustomFormat   = "yyyy-MM-dd";
    dtp.Format         = DateTimePickerFormat.Custom;
      

  3.   

    DateTimePicker dtp = new DateTimePicker();
    dtp.CustomFormat   = "yyyy-MM-dd";
    dtp.Format         = DateTimePickerFormat.Custom;
    ……………………………………………………
    怎么对 dtp 赋值呢?
      

  4.   

    用3个DropDownList不好吗?不用用户输入自己有不用处理得那么麻烦
      

  5.   

    曾经写过一个这样的控件
    <OBJECT id=txtPost origvalue="##fld##_unmask=" classid="CLSID:98A52828-A5D6-11D3-82B8-00104B39A31D" height=18 style="WIDTH: 100%;" VIEWASTEXT tabindex=24>
    <PARAM NAME="MaxLength" VALUE="40">
    <PARAM NAME="Mask" VALUE="99999-9999">
    <PARAM NAME="Text" VALUE="">
    <PARAM NAME="Enabled" VALUE="1">
    <PARAM NAME="MaskRules" VALUE="2">
    <PARAM NAME="PromptChar" VALUE="_">
    </OBJECT>