| Skype: | TextControlSupport | |
| Orders: | 877-462-4772 |

| Author: | TX Text Control Support Department |
| Language: | C# .NET |
| Version: | 1.0 |
| Released: | November 05, 2007 |
| Last modified: | January 11, 2008 |
| Requirements: | TX Text Control .NET with C# .NET |
| Download code: | tx_sample_line_numbering.zip |

A typical application for TX Text Control is software for medical transcription companies. This software is used by transcriptionists to type dictated medical results or similar.
These applications must display the current line number on the document that must not be saved within the document. For this purpose, GDI+ can be used to render the text on the page margin. The Line collection returns the positions for each line number that makes this approach very effortless.
The following function simply loops through all lines to retrieve the position of each line where the specific line number will be rendered using GDI+.
private Brush LINE_COLOR = new SolidBrush(Color.Gray); private int LINE_DISTANCE = 40; private void setLineNumbering() { textControl1.Refresh(); Graphics g = textControl1.CreateGraphics(); int DPI = (int)(1440 / g.DpiX); foreach (TXTextControl.Line line in textControl1.Lines) { g.DrawString(line.Number.ToString() + ":", new Font(textControl1.Font.Name, textControl1.Font.Size), LINE_COLOR, new PointF(((line.TextBounds.X / DPI) - LINE_DISTANCE) - (textControl1.ScrollLocation.X / DPI), (line.TextBounds.Top / DPI) - (textControl1.ScrollLocation.Y / DPI))); } }
This function must be called in the Changed, InputPositionChanged, VScroll and HScroll events to get the best results.
The minimum requirements for this sample application are TX Text Control .NET trial version and Visual Studio 2005.