How can I set a DateTimePicker control to a specific date?

Mike picture Mike · Feb 12, 2009 · Viewed 162.4k times · Source

How can I set a DateTimePicker control to a specific date (yesterday's date) in C# .NET 2.0?

Answer

Rowland Shaw picture Rowland Shaw · Feb 12, 2009

Just need to set the value property in a convenient place (such as InitializeComponent()):

    dateTimePicker1.Value = DateTime.Today.AddDays(-1);