Hello,
Apologies for my very novice questions. I have a form used as a scheduler and need to alter my date picker to exclude weekends. I located the following code online however I cannot get the message box to display what the code indicates it will display.
Also, I am only prohibited on my first attempt at choosing a weekend date. Additional attempts are allowed. I want all Saturday/Sunday dates to be prohibited.
System.DateTime myDate = DateTime.Now();
String myDateString="";
private void dateTimePicker1_ValueChanged(object sender, System.EventArgs e)
{
System.DayOfWeek i = myDate.DayOfWeek;
if((i == System.DayOfWeek.Sunday) || (i == System.DayOfWeek.Saturday))
{
MessageBox.Show("Please try again, can't select a weekend day");
myDateString = dateTimePicker1.Value.ToString();
return;
}
else
myDateString = dateTimePicker1.Value.ToString();
}
***Post moved by the moderator to the appropriate forum category.***