none
Insert Date in Date Time Picker

    Question

  • Hello,
    in my programm I use DateTimePicker to permit to user to change dates.
    But can user insert the input date with keys?
    Can jump date, for example jan 1890 to feb 1999, without run all months?

    Thanks,
    Mauro

    Thursday, November 01, 2007 9:36 AM

Answers

  • Oh, that is simple:

     

    Code Block
    dateTimePicker1.Value =
    DateTime.Parse("01/01/1950");

     

     

    From here you can choose the way your going to allow the user to jump to a specific date. I would recommend you to use the masked text box using format = "##/##/####".

     

    Hope this helps,

    Regards,

    Fábio

    Monday, November 05, 2007 10:51 AM

All replies

  • Humm, not sure what you really want. How do you want this to work? See if this example suits you:

     

     

    Code Block

    DateTime date = DateTime.Now;

    date.AddYears(10);

     

     

     

     

    this will make the date to 01/11/2017

    Thursday, November 01, 2007 10:43 AM
  •  

    Hi Fabio,

    it's not what I wanted to obtain.

    I'm probably not well explained.
    When user open the data time picker control, the monthCalendar is in the position of the date.
    But if the user wants to go to another date not near to Date Time Picker's current date (for example from 1900 to 1950), it takes long time pressing previous or forward button in DTPicker Control, to go to the new data. Can User to jump to the new data (not Now, in this case he can) maybe with input keys, or I have to use antother control (For example ComboBox with items as years) to permit the jump?
    Thanks and regards,
    Mauro

    Thursday, November 01, 2007 7:08 PM
  • Oh, that is simple:

     

    Code Block
    dateTimePicker1.Value =
    DateTime.Parse("01/01/1950");

     

     

    From here you can choose the way your going to allow the user to jump to a specific date. I would recommend you to use the masked text box using format = "##/##/####".

     

    Hope this helps,

    Regards,

    Fábio

    Monday, November 05, 2007 10:51 AM
  • Hello Fabio,
    I solved my problem it was just as input new date.
    I've set:

    Me.DateTimePicker1.Format = System.Windows.Forms.DateTimePickerFormat.Custom

    Me.DateTimePicker1.CustomFormat = "MMM yy"

     

    In this case if user select the Month he can't modified it (my doubt was born here), but can modified the year if it's selected.
    Thank and regards,
    Mauro



     

     

     

     

     

     

    Tuesday, November 06, 2007 10:19 PM