Skip to content

Use the Visitor-Iterator pattern to enclose bold text in asterisks and return all characters without formatting. Paragraph ends are replaced with newline symbols, other document elements are skipped.

License

Notifications You must be signed in to change notification settings

DevExpress-Examples/winforms-richedit-iterate-over-document-elements

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WinForms Rich Text Editor - How to Use the Document Iterator Object to Iterate over Document Elements

The following example shows how to use the Visitor-Iterator pattern to format document text:

  • Enclose bold text in asterisks
  • Return all characters without formatting
  • Replace paragraph ends with newline symbols

Other document elements are skipped.

Implementation Details

This example creates a DocumentIterator instance for the current document and calls its 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 Accept method with the MyVisitor object instance as a parameter.

MyVisitor is a custom class that descends from the DocumentVisitorBase class. It contains a method that processes DocumentText elements to enclose bold text in asterisks and return all characters without formatting. Paragraph ends are replaced with newline symbols, other document elements are skipped.

Files to Review

Documentation

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

About

Use the Visitor-Iterator pattern to enclose bold text in asterisks and return all characters without formatting. Paragraph ends are replaced with newline symbols, other document elements are skipped.

Topics

Resources

License

Stars

Watchers

Forks