ITextRangeProvider.ExpandToEnclosingUnit Method (TextUnit)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Expands the text range to the specified text unit.

Namespace:   System.Windows.Automation.Provider
Assembly:  UIAutomationProvider (in UIAutomationProvider.dll)

void ExpandToEnclosingUnit(
	TextUnit unit
)

Parameters

unit
Type: System.Windows.Automation.Text.TextUnit

The textual unit.

If the range is already an exact quantity of the specified units then it remains unchanged.

There is a series of steps are involved behind the scenes in order for the Move method to execute successfully.

  1. The text range is normalized; that is, the text range is collapsed to a degenerate range at the Start endpoint, which makes the End endpoint superfluous. This step is necessary to remove ambiguity in situations where a text range spans unit boundaries; for example, "{The U}RL http://www.microsoft.com is embedded in text" where "{" and "}" are the text range endpoints.

  2. The resulting range is moved backward in the DocumentRange to the beginning of the requested unit boundary.

  3. The range is moved forward or backward in the DocumentRange by the requested number of unit boundaries.

  4. The range is then expanded from a degenerate range state by moving the End endpoint by one requested unit boundary.

 

Range adjustments by Move & ExpandToEnclosingUnit

Examples of how a text range is adjusted for Move() and ExpandToEnclosingUnit()

System_CAPS_noteNote

These steps are necessary since it is common for a screen reader to read out a full word, sentence, or entire paragraph at the insertion point or any virtual cursor position.

ExpandToEnclosingUnit respects both hidden and visible text.

ExpandToEnclosingUnit defers to the next largest TextUnit supported if the given TextUnit is not supported by the control.

The order, from smallest unit to largest, is listed below.

.NET Framework
Available since 3.0
Silverlight
Available since 4.0
Windows Phone Silverlight
Available since 7.1
Return to top
Show: