In my program there are two datetimepickers. I need to get the days in between the chosen dates and store them into a list or array. All these are to be done in the second datetimepicker value changed event
private void dateTimePickertodate_ValueChanged(object sender, EventArgs e)
{
if (dateTimePickertodate.Value <=dateTimePickerfromdate.Value)
{
MessageBox.Show("Choose Correct date");
textBoxnumofdays.Clear();
}
else
{
cleave = new LeaveApplication(constr);
TimeSpan span = dateTimePickertodate.Value - dateTimePickerfromdate.Value;
if (Mode == 1)
{
textBoxnumofdays.Text = Convert.ToString(span.Days + 2);
}
else
{
textBoxnumofdays.Text = Convert.ToString(span.Days + 1);
}
}
}
You may try something on these lines
days would have your week days list (if this is what you intent to have)