System.Windows.Automation.Text.TextPatternRange.Select C# (CSharp) 메소드

Select() 공개 메소드

public Select ( ) : void
리턴 void
        public void Select()
        {
            try
            {
                this._range.Select();
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
            }
        }

Usage Example

예제 #1
0
        /// --------------------------------------------------------------------
        /// <summary>
        ///     Gets the enclosing element of the target selection.
        /// </summary>
        /// <param name="sender">The object that raised the event.</param>
        /// <param name="e">Event arguments.</param>
        /// --------------------------------------------------------------------
        private void GetEnclosingElement_Click(object sender, RoutedEventArgs e)
        {
            // Obtain the enclosing element.
            AutomationElement enclosingElement;
            try
            {
                enclosingElement = _searchRange.GetEnclosingElement();
            }
            catch (ElementNotAvailableException)
            {
                // TODO: error handling.
                return;
            }

            // Assemble the information about the enclosing element.
            var enclosingElementInformation = new StringBuilder();
            enclosingElementInformation.Append(
                "Enclosing element:\t").AppendLine(
                    enclosingElement.Current.ControlType.ProgrammaticName);

            // The WPF target doesn't show selected text as highlighted unless
            // the window has focus.
            _targetWindow.SetFocus();

            // Display the enclosing element information in the client.
            _targetSelectionDetails.Text = enclosingElementInformation.ToString();

            // Is the enclosing element the entire document?
            // If so, select the document.
            if (enclosingElement == _targetDocument)
            {
                _documentRange = _targetTextPattern.DocumentRange;
                _documentRange.Select();
                return;
            }
            // Otherwise, select the range from the child element.
            var childRange =
                _documentRange.TextPattern.RangeFromChild(enclosingElement);
            childRange.Select();
        }
All Usage Examples Of System.Windows.Automation.Text.TextPatternRange::Select