namespace CustomsComponentsVar2; public partial class CustomDateTimePicker : UserControl { public CustomDateTimePicker() { InitializeComponent(); } public event EventHandler _dateChanged; public DateTime dateStart; public DateTime dateEnd; public DateTime date { get { if (dateStart == null || dateEnd == null) { throw new RangeNotSetException("Не задан диапазон."); } if (date < dateStart && date > dateEnd) { throw new ValueNotInRangeException("Значение не входит в диапазон"); } return date; } set { if (value >= dateStart && value <= dateEnd) { date = value; } } } public void dateChanged(DateTime date) { _dateChanged?.Invoke(this, date); } }