Click or drag to resize
TextRangeExpand Method
Expands this range so that any partial units it contains are completely contained.

Namespace: TextObjectModel
Assembly: ManagedTOM2 (in ManagedTOM2.dll) Version: 1.0.5577.41188
Syntax
public int Expand(
	TextUnit unit
)

Parameters

unit
Type: TextObjectModelTextUnit
Unit to include.

Return Value

Type: Int32
The count of characters added to the range.
Examples
The following example demonstrates the effect of collapsing and expanding a range:
C#
void ExpandCollapseExample(TextDocument document) {
    TextRange range = document.EntireRange;
    range.Text = "Collapse";

    // range is now (0,8)
    Console.WriteLine("Range is now ({0}, {1})", range.Start, range.Length);

    range.Collapse(RangePosition.Start);

    // range is now (0,0)
    Console.WriteLine("Range is now ({0}, {1})", range.Start, range.Length);

    range.Expand(TextUnit.Word);
    range.Collapse(RangePosition.End);

    // range is now (8,0)
    Console.WriteLine("Range is now ({0}, {1})", range.Start, range.Length);
}
See Also