Example #1
0
        void ValueEditor_TextChanged3(object sender, EventArgs e)
        {
            TextBox textBox = sender as TextBox;

            if (textBox != null && textBox.Text.Length >= 4)
            {
                int years = Convert.ToInt32(textBox.Text);

                if (years < 10000)
                {
                    textBox.Text = string.Format("{0:0000}", years);
                    okButton.Focus();
                }
                else
                {
                    textBox.Text = textBox.Text.Substring(0, years >= 10000 ? 4 : 3);
                    textBox.Select(4, 1);
                }
            }
        }