Implementing Split Views

Many editors offer split-views of a document, allowing you to keep a part of the document visible while you work on another part.

You can achieve this easily by connecting two or more C1RichTextBox controls to the same underlying C1Document. Each control acts as an independent view, allowing you to scroll, select, and edit the document as usual. Changes made to one view are reflected on all other views.

To show how this works, let's extend the previous example by adding a few lines of code to the page constructor:

      Visual Basic

      C#

The new code adds a new C1RichTextBox to the page and then sets its Document property to the document being shown by the original C1RichTextBox.

If you run the project again, you will see a window like the one shown below:

 

 

The bottom control is editable (we did not set its IsReadOnly property to False). If you type into it, you will see the changes on both controls simultaneously.

The mechanism is general; we could easily attach more views of the same document. Moreover, any changes you make to the underlying document are immediately reflected on all views.


Send us comments about this topic.
Copyright © GrapeCity, inc. All rights reserved.