DocumentIterator Class
Iterates over document elements.
Namespace: DevExpress.XtraRichEdit.API.Native
Assembly: DevExpress.RichEdit.v24.2.Core.dll
NuGet Package: DevExpress.RichEdit.Core
Declaration
Related API Members
The following members return DocumentIterator objects:
Remarks
The DocumentIterator object enables you to iterate over document elements in a specified document range. To accomplish this, create a new DocumentIterator instance and call its DocumentIterator.MoveNext method until it returns false. For each step, the current document element is obtained with the DocumentIterator.Current property.
This example creates a DocumentIterator
instance for the current document and calls its DocumentIterator.MoveNext method to iterate over document elements. A Visitor pattern is implemented to process a document element. The implementation is done by calling each element’s IDocumentElement.Accept method with the MyVisitor object instance as a parameter. MyVisitor object implements the IDocumentVisitor interface and overrides its IDocumentVisitor.Visit methods to perform required actions when an iterator encounters a certain document element ( an instance of the class inherited form the DocumentElementBase class).
MyVisitor visitor = new MyVisitor();
DocumentIterator iterator = new DocumentIterator(richEditControl1.Document, true);
while (iterator.MoveNext())
iterator.Current.Accept(visitor);
memoEdit1.Text = visitor.Text;