It is necessary that when selecting a specific date, a message would be displayed via if, for example, if 2018, 12, 19 is selected to display the word Holiday
private void dateTimePicker1_ValueChanged(object sender, EventArgs e) { dateTimePicker1.MinDate = new DateTime(1985, 6, 20); dateTimePicker1.MaxDate = DateTime.Today; //if (dateTimePicker1.Value = 2018 , 12, 18) { MessageBox.Show("Holliday"); } }
dateTimePicker1.Value? Right,DateTime. What do we compare values with? With an object of the same type. How is the comparison going? Two characters equals (==). Based on this, what conclusion do we come to? - EvgeniyZdateTimePicker1.MaxDate = DateTime.Today;The control will not accept the date higher than the current, choosing instead the last available (16). By the way, such a restriction in the event does not make sense, it is enough to register in the constructor, or once during the form initialization (for example). - EvgeniyZ