Exemple #1
0
        private void FocusOnDatePart(int selStart)
        {
            ReformatDateText();

            string df = DateFormat;

            if (selStart > df.Length - 1)
            {
                selStart = df.Length - 1;
            }
            char firstchar = df[selStart];

            while (!char.IsLetter(firstchar) && selStart + 1 < df.Length)
            {
                selStart++;
                firstchar = df[selStart];
            }
            while (selStart > 0 && df[selStart - 1] == firstchar)
            {
                selStart--;
            }

            int selLength = 1;

            while (selStart + selLength < df.Length && df[selStart + selLength] == firstchar)
            {
                selLength++;
            }

            DateDisplay.Focus();
            DateDisplay.Select(selStart, selLength);
        }
        private void FocusOnDatePart(int selstart)
        {
            if (selstart > DateFormat.Length - 1)
            {
                selstart = DateFormat.Length - 1;
            }
            char firstchar = Convert.ToChar(DateFormat.Substring(selstart, 1));

            selstart = DateFormat.IndexOf(firstchar);
            int sellength = Math.Abs((selstart - (DateFormat.LastIndexOf(firstchar) + 1)));

            DateDisplay.Focus();
            DateDisplay.Select(selstart, sellength);
        }
Exemple #3
0
        private bool FocusOnDatePart(int selStart)
        {
            ReformatDateText();

            // Find beginning of field to select
            var df = DateFormat;

            if (selStart > df.Length - 1)
            {
                selStart = df.Length - 1;
            }
            var firstchar = df[selStart];

            while (!char.IsLetter(firstchar) && selStart + 1 < df.Length)
            {
                selStart++;
                firstchar = df[selStart];
            }
            while (selStart > 0 && df[selStart - 1] == firstchar)
            {
                selStart--;
            }

            var selLength = 1;

            while (selStart + selLength < df.Length && df[selStart + selLength] == firstchar)
            {
                selLength++;
            }

            // don't select AM/PM: we have no interface to change it. - We have now
            if (firstchar == 't')
            {
                selLength = 2;
            }
            //return false;

            DateDisplay.Focus();
            DateDisplay.Select(selStart, selLength);
            return(true);
        }