/// <summary> /// Initializes a new instance of the <see cref="InputDateTextBox"/> class. /// </summary> /// <param name="parent">The parent of the control.</param> public InputDateTextBox(DatePickerDateTextBox parent) { if (parent == null) { throw new ArgumentNullException("parent"); } this.BorderStyle = BorderStyle.None; this.BackColor = parent.BackColor; }
/// <summary> /// Initializes a new instance of the <see cref="InputDateTextBox"/> class. /// </summary> /// <param name="parent">The parent of the control.</param> public InputDateTextBox(DatePickerDateTextBox parent) { if (parent == null) { throw new ArgumentNullException("parent"); } this.parent = parent; this.BorderStyle = BorderStyle.None; this.BackColor = parent.BackColor; }
/// <summary> /// Initializes a new instance of the <see cref="DatePicker"/> class. /// </summary> public DatePicker() { this.SetStyle( ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.Selectable, true); this.borderColor = Color.FromArgb(127, 157, 185); this.focusedBorderColor = Color.Blue; this.Width = 101; this.Height = 22; this.AllowPromptAsInput = false; this.monthCalendar = new MonthCalendar { SelectionMode = MonthCalendarSelectionMode.Day }; this.monthCalendar.KeyPress += this.MonthCalendarKeyPress; this.dateTextBox = new DatePickerDateTextBox(this) { Font = this.Font, Location = new Point(2, 2), Date = DateTime.Today, Width = this.Width - 19, Height = 18, MinDate = this.monthCalendar.MinDate, MaxDate = this.monthCalendar.MaxDate }; this.dateTextBox.CheckDate += this.DateTextBoxCheckDate; this.dateTextBox.GotFocus += this.FocusChanged; this.dateTextBox.LostFocus += this.FocusChanged; this.Controls.Add(this.dateTextBox); this.monthCalendar.DateSelected += this.MonthCalendarDateSelected; this.monthCalendar.ActiveDateChanged += this.MonthCalendarActiveDateChanged; this.monthCalendar.DateClicked += this.MonthCalendarDateClicked; this.monthCalendar.InternalDateSelected += this.MonthCalendarInternalDateSelected; this.monthCalendar.GotFocus += this.FocusChanged; this.monthCalendar.LostFocus += this.FocusChanged; this.monthCalendarHost = new ToolStripControlHost(this.monthCalendar); this.monthCalendarHost.LostFocus += this.MonthCalendarHostLostFocus; this.monthCalendarHost.GotFocus += this.FocusChanged; this.dropDown = new CustomToolStripDropDown { DropShadowEnabled = true }; this.dropDown.Closing += this.DropDownClosing; this.dropDown.GotFocus += this.FocusChanged; this.dropDown.LostFocus += this.FocusChanged; this.dropDown.Items.Add(this.monthCalendarHost); this.monthCalendar.MonthMenu.OwnerItem = this.monthCalendarHost; this.monthCalendar.YearMenu.OwnerItem = this.monthCalendarHost; this.monthCalendar.MonthMenu.ItemClicked += this.MenuItemClicked; this.monthCalendar.YearMenu.ItemClicked += this.MenuItemClicked; this.BackColor = SystemColors.Window; this.ClosePickerOnDayClick = true; }