CreateAnchor Method (offset)
Creates a new ITextAnchor at the specified offset.
Declaration Syntax
C#Visual BasicVisual C++
ITextAnchor CreateAnchor(
	int offset
Function CreateAnchor ( _
	offset As Integer _
) As ITextAnchor
ITextAnchor^ CreateAnchor(
	int offset
offset (Int32)

Use the Offset property to get the offset from a text anchor. Use the CreateAnchor(Int32) method to create an anchor from an offset.

The document will automatically update all text anchors; and because it uses weak references to do so, the garbage collector can simply collect the anchor object when you don't need it anymore.

Moreover, the document is able to efficiently update a large number of anchors without having to look at each anchor object individually. Updating the offsets of all anchors usually only takes time logarithmic to the number of anchors. Retrieving the Offset property also runs in O(lg N).

 Copy imageCopy
TextAnchor anchor = document.CreateAnchor(offset);
            int newOffset = anchor.Offset;

Assembly: ICSharpCode.AvalonEdit (Module: ICSharpCode.AvalonEdit.dll) Version: