This message contains graphics. If you do not see the graphics: Graphic Version.
 
How to insert leading dots before tab positions

Everybody knows them: the small leading dots between the items and the prices on a menu card or between a heading and a page number in a table of contents.

The screenshot to the right illustrates this principle.

This week we would like to show you a simple way to insert these leading dots in TX Text Control .NET for Windows Forms. The technique that we describe is very simple, but at the same time, very efficient. When the user presses the tab key, the gap between the text and the next tab position is filled with dots.

How to do that? First of all, we store the starting position on the KeyDown event. We need this position to know where to start with the dots.

In the KeyUp event, we store the new input position, which is our end position. After that we use a loop to insert the dots using the Text property of the current selection. It loops until the current position equals the end position we stored previously.

We use the InputPosition class to compare the horizontal positions. That is all there is to it.

Do While startPosLocation.X <= endPosLocation.X - 40 TextControl1.Selection.Text = "." startPosLocation = TextControl1.InputPosition.Location Loop

As mentioned, this is a very basic method to insert these leading dots. Consider improvements like reordering the dots, if the tab position has been changed. This is more complex as you have to store the paragraphs where leading dots have been inserted.

The minimum requirements for this sample application are TX Text Control .NET for Windows Forms trial version and Visual Studio .NET 2003.


Best regards

The Newsletter Team

Text Control GmbH respects your online time and privacy. We only send this newsletter to TX Text Control customers and people who have signed up to receive it. However, if you would prefer not to receive future issues of the newsletter, you may unsubscribe at any time. If you received this newsletter forwarded from a colleague or friend, you may wish to subscribe directly.

Sent to: N/A.

Imprint | Unsubscribe | Subscribe

© 2019 Text Control GmbH. All Rights Reserved.