ITextRangeProvider.MoveEndpointByUnit Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Moves one endpoint of the text range the specified number of text units within the document range.
public:
int MoveEndpointByUnit(System::Windows::Automation::Text::TextPatternRangeEndpoint endpoint, System::Windows::Automation::Text::TextUnit unit, int count);
public int MoveEndpointByUnit (System.Windows.Automation.Text.TextPatternRangeEndpoint endpoint, System.Windows.Automation.Text.TextUnit unit, int count);
abstract member MoveEndpointByUnit : System.Windows.Automation.Text.TextPatternRangeEndpoint * System.Windows.Automation.Text.TextUnit * int -> int
Public Function MoveEndpointByUnit (endpoint As TextPatternRangeEndpoint, unit As TextUnit, count As Integer) As Integer
Parameters
- endpoint
- TextPatternRangeEndpoint
The endpoint to move.
- unit
- TextUnit
The textual unit for moving.
- count
- Int32
The number of units to move. A positive value moves the endpoint forward. A negative value moves backward. A value of 0 has no effect.
Returns
The number of units actually moved, which can be less than the number requested if moving the endpoint runs into the beginning or end of the document.
Remarks
When it is necessary to traverse the content of a text range, a series of steps are involved behind the scenes in order for the Move method to execute successfully.
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 https://www.microsoft.com/ is embedded in text" where "{" and "}" are the text range endpoints.The resulting range is moved backward in the DocumentRange to the beginning of the requested
unit
boundary.The range is then expanded from a degenerate range state by moving the End endpoint by one requested
unit
boundary.
Examples of how a text range is adjusted for Move() and ExpandToEnclosingUnit()
MoveEndpointByUnit 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.