Example #1
0
        public DateControl()
        {
            CanGoBackward         = true;
            CanGoForward          = false;
            this.ParentChanged   += DateControl_ParentChanged;
            Wrapper               = new System.Windows.Forms.FlowLayoutPanel();
            Wrapper.FlowDirection = System.Windows.Forms.FlowDirection.LeftToRight;
            Wrapper.Margin        = System.Windows.Forms.Padding.Empty;
            Wrapper.Dock          = System.Windows.Forms.DockStyle.Fill;
            Year        = new NumericTextBox();
            YearMonth   = new System.Windows.Forms.Label();
            Month       = new NumericTextBox();
            MonthDay    = new System.Windows.Forms.Label();
            Day         = new NumericTextBox();
            this.Enter += Atiran2DateControl_Enter;

            //set Today values

            string today = TodayFullChar();

            Year.Text = today.Substring(0, 4);

            Month.Text = today.Substring(5, 2);

            Day.Text = today.Substring(8, 2);

            Day.TextChanged   += Day_TextChanged;
            Month.TextChanged += Month_TextChanged;

            Day.Leave   += Day_Leave;
            Month.Leave += Month_Leave;
            Year.Leave  += Year_Leave;
            //Year
            Year.TabIndex  = 2;
            Year.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            SetTextBoxWidthAndHeight(Year, 4);
            RemoveMargin(Year);
            RemoveBorder(Year);
            Wrapper.Controls.Add(Year);

            RemoveMargin(YearMonth);
            YearMonth.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            YearMonth.Text      = "/";
            YearMonth.BackColor = Color.White;
            YearMonth.AutoSize  = true;
            Wrapper.Controls.Add(YearMonth);
            Month.TabIndex  = 1;
            Month.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            SetTextBoxWidthAndHeight(Month, 2);
            RemoveBorder(Month);
            RemoveMargin(Month);
            Wrapper.Controls.Add(Month);

            RemoveMargin(MonthDay);
            MonthDay.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            MonthDay.Height    = this.Height;
            MonthDay.Text      = "/";
            MonthDay.BackColor = Color.White;
            MonthDay.AutoSize  = true;

            Wrapper.Controls.Add(MonthDay);
            Day.TabIndex  = 0;
            Day.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            SetTextBoxWidthAndHeight(Day, 2);
            RemoveBorder(Day);
            RemoveMargin(Day);
            Day.Height = this.Height;
            Wrapper.Controls.Add(Day);
            this.Controls.Add(Wrapper);
            this.FontChanged   += DateControl_FontChanged;
            Day.KeyDown        += Day_KeyDown;
            Month.KeyDown      += Month_KeyDown;
            Year.KeyDown       += Year_KeyDown;
            YearMonth.BackColor = Year.LeaveBaCkColor;
            MonthDay.BackColor  = Year.LeaveBaCkColor;
            YearMonth.ForeColor = Year.LeaveForColor;
            MonthDay.ForeColor  = Year.LeaveForColor;
        }