Roelzkie
Roelzkie

Reputation: 61

DateTimePicker to restrict by Year choices in dropdown

Is it possible to restrict DateTimePicker only by year choices when dropping down the calendar?

Upvotes: 1

Views: 648

Answers (1)

Salah Akbari
Salah Akbari

Reputation: 39946

Do the following steps:

  • Change the property of the DateTimePicker's Format to Custom like this:

    dateTimePicker1.Format = DateTimePickerFormat.Custom;
    
  • Change the CustomFormat to yyyy like this:

    dateTimePicker1.CustomFormat = "yyyy";
    
  • Set the ShowUpDown property to true or false as you want like this:

    dateTimePicker1.ShowUpDown = true;
    

Upvotes: 1

Related Questions