Click or drag to resize
TextRangeMoveWhile Method
Starts at the end of the range and searches while the characters belong to the set specified by chars. The range is collapsed to an insertion point when a non-matching character is found.

Namespace: TextObjectModel
Assembly: ManagedTOM2 (in ManagedTOM2.dll) Version: 1.0.5577.41188
Syntax
public int MoveWhile(
	params char[] chars
)

Parameters

chars
Type: SystemChar
The character set to use in the match.

Return Value

Type: Int32
The number of characters the insertion point is moved.
Exceptions
ExceptionCondition
ArgumentNullExceptionchars is null.
Examples
The following example demonstrates the various move methods:
C#
void MoveExamples(TextDocument document) {
    TextRange range = document.EntireRange;
    range.Text = "One two three four";
    range.Collapse(RangePosition.Start);

    range.Move(TextUnit.Word, 1);
    range.MoveEnd(TextUnit.Character, 3);

    // range text is now "two"
    Console.WriteLine("Range text is now: {0}", range.Text);

    range.MoveEndWhile(' ', 't', 'r');

    // range text is now "two t"
    Console.WriteLine("Range text is now: {0}", range.Text);

    range.MoveEndUntil(' ');

    // range text is now "two three"
    Console.WriteLine("Range text is now: {0}", range.Text);

    range.MoveStart(TextUnit.Word, 1);

    // range text is now "three"
    Console.WriteLine("Range text is now: {0}", range.Text);

    range.MoveStartWhile('t');

    // range text is now "hree"
    Console.WriteLine("Range text is now: {0}", range.Text);

    range.MoveStartUntil('e', 'r');

    // range text is now "ree"
    Console.WriteLine("Range text is now: {0}", range.Text);

    range.MoveWhile(' ', 'f');
    range.Text = "ive";

    range.MoveUntil('o');
    range.Text = " f";

    range.Expand(TextUnit.Story);

    // range text is now "One two three five four"
    Console.WriteLine("Range text is now: {0}", range.Text);
}
See Also