How to Disable Previous Date in DateTimePicker Using C#

Submitted by: 
Language: 
Visitors have accessed this post 178 times.

In this tutorial I will teach you how to disable previous date in the datetimepicker using c#. This simple program will help you for filtering the date displayed in the datetimepicker. It will disable the dates in the calendar beyond the current date. Hope this simple program will help you if you encounter this kind of problem. Let’s begin.

Creating a Program

Step 1

Open Microsoft Visual Studio 2015 and create a new windows form application.
ps1\

Step 2

Do the form just like shown below.
ps2

Step 3

Double click the “Disable” button and add the following code to disable the previous date when the button is clicked.

  1.  
  2. dateTimePicker1.MinDate = DateTime.Now;

Step 4

Double click the “Enable” button and add the following code to enable the previous date when the button is clicked.

  1.  
  2. dateTimePicker1.MinDate = DateTime.Parse("01/01/1753");

Output
ps3


Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.