When using any other view mode than the PageView mode, page-oriented features such as margins are not visible. This sample shows how to add TextControl to a container panel to simulate a margin and how to integrate custom scroll bars.

FloatingText ViewMode

The following screenshot shows a TextControl TX Text Control .NET for Windows Forms
TXTextControl Namespace
TextControl Class
The TextControl class implements a Windows Forms control with high-level text editing features.
object on a form with the ViewMode TX Text Control .NET for Windows Forms
TXTextControl Namespace
TextControl Class
ViewMode Property
Gets or sets the mode how Text Control displays a document.
property set to FloatingText.

ViewMode

According to the documentation, this view mode has specific settings and limitations:

FloatingText

This view mode provides a vertical scrollbar to enable unlimited text content. The maximum horizontal text extent is the horizontal size of the control. The values of the PageSize and PageMargins properties are ignored. Headers and footers are not displayed.

As you can see in the screenshot, the text is directly aligned with the border of the control. But in some applications, a border or a margin should be displayed when using this view mode.

Adding a Panel

An obvious idea is to place the TextControl into a panel with the same background color like the page color and a specific padding enabled:

ViewMode

Now, there is a visible margin, but the scrollbar is inside the new padding as well. In order avoid that, a custom scrollbar must be implemented. The following screenshot shows the custom control that consists of two panels, a vertical scrollbar and a TextControl.

ViewMode

When docked and used on a form, you can see a working scrollbar and a visible margin when using the FloatingText view mode:

ViewMode

The following code is mirroring the maximum scrollbar value of the custom scrollbar with the ScrollLocation TX Text Control .NET for Windows Forms
TXTextControl Namespace
TextControl Class
ScrollLocation Property
Gets or sets the coordinates, in twips, of the upper-left corner of the document's visible part relative to the upper-left corner of the complete document.
property of TextControl.

Loading...

Feel free to test this on your own by downloading the sample from our GitHub repository.