/// <devdoc>
        ///     Validates the last unvalidated control and its ancestors up through (but not including) ancestorControl.
        /// </devdoc>
        /// <internalonly/>
        private bool ValidateThroughAncestor(Control ancestorControl)
        {
            if (ancestorControl == null)
            {
                ancestorControl = this;
            }
            if (validating)
            {
                return(false);
            }
            if (unvalidatedControl == null)
            {
                unvalidatedControl = focusedControl;
            }
            //return true for a Container Control with no controls to validate....
            //
            if (unvalidatedControl == null)
            {
                return(true);
            }
            if (!ancestorControl.IsDescendant(unvalidatedControl))
            {
                return(false);
            }

            this.validating = true;
            bool cancel = false;

            Control currentActiveControl     = activeControl;
            Control currentValidatingControl = unvalidatedControl;

            if (currentActiveControl != null)
            {
                currentActiveControl.ValidationCancelled = false;
            }
            try {
                while (currentValidatingControl != ancestorControl)
                {
                    if (currentValidatingControl.CausesValidation)
                    {
                        bool validationCancelled = false;

                        try {
                            validationCancelled = currentValidatingControl.NotifyValidating();
                        }
                        catch (Exception) {
                            // if the handler threw, we have to cancel
                            cancel = true;
                            throw;
                        }

                        // check whether the handler said cancel
                        if (validationCancelled)
                        {
                            cancel = true;
                            break;
                        }
                        else
                        {
                            try {
                                currentValidatingControl.NotifyValidated();
                            }
                            catch (Exception e) {
                                Application.OnThreadException(e);
                            }
                        }
                    }

                    currentValidatingControl = currentValidatingControl.ParentInternal;
                }

                if (cancel)
                {
                    if (currentActiveControl == activeControl)
                    {
                        if (currentActiveControl != null)
                        {
                            CancelEventArgs ev = new CancelEventArgs();
                            ev.Cancel = true;
                            currentActiveControl.NotifyValidationResult(currentValidatingControl, ev);
                            if (currentActiveControl is ContainerControl)
                            {
                                ContainerControl currentActiveContainerControl = currentActiveControl as ContainerControl;
                                if (currentActiveContainerControl.focusedControl != null)
                                {
                                    currentActiveContainerControl.focusedControl.ValidationCancelled = true;
                                }
                                currentActiveContainerControl.ResetActiveAndFocusedControlsRecursive();
                            }
                        }
                    }
                    SetActiveControlInternal(unvalidatedControl);
                }
            }
            finally {
                unvalidatedControl = null;
                validating         = false;
            }

            return(!cancel);
        }