Hi Sumanta,
The following code example demonstrates how use the Value property to retrieve the current date value. First, the example displays the Value property. The example then increments the Value property by one day and displays the property value again.
public MyClass()
{
// Create a new DateTimePicker
DateTimePicker dateTimePicker1 = new DateTimePicker();
Controls.AddRange(new Control[] {dateTimePicker1});
MessageBox.Show(dateTimePicker1.Value.ToString());
dateTimePicker1.Value = DateTime.Now.AddDays(1);
MessageBox.Show(dateTimePicker1.Value.ToString());
}
Now If you want to compare the value of dateTimePicker to the system date, this can be achieved by the following code
private void dpEndD_Validating(object sender, CancelEventArgs e)
{
if (dateTimePicker1.Value == System.DateTime.Now.Date)
{
MessageBox.Show("Date-Time Picker is correct");
}
}
Dec 28, 2010