Skype:TextControlSupport
Orders:877-462-4772
TX Text Control - word processing components.
What is this?Syndicate this content

Legal documents: Display line numbers on the page margin

This source code snippet requires TX Text Control .NET
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 Download [14.85 KB, ZIP]
Click to enlarge

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+.

  1. private Brush LINE_COLOR = new SolidBrush(Color.Gray);
  2. private int LINE_DISTANCE = 40;
  3.  
  4. private void setLineNumbering()
  5. {
  6. textControl1.Refresh();
  7. Graphics g = textControl1.CreateGraphics();
  8. int DPI = (int)(1440 / g.DpiX);
  9.  
  10. foreach (TXTextControl.Line line in textControl1.Lines)
  11. {
  12. g.DrawString(line.Number.ToString() + ":",
  13. new Font(textControl1.Font.Name, textControl1.Font.Size),
  14. LINE_COLOR,
  15. new PointF(((line.TextBounds.X / DPI) - LINE_DISTANCE) -
  16. (textControl1.ScrollLocation.X / DPI),
  17. (line.TextBounds.Top / DPI) - (textControl1.ScrollLocation.Y / DPI)));
  18. }
  19. }

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.

top

Top 10 Bestselling Product Award 2007Top 25 Publisher Product Award 2007Top 10 Bestselling Product Award 2007 in JapanTop 25 Bestselling Product Award 2006Top 25 Bestselling Publisher Award 2006Reader's Choice Award, dot.net magazin, 3rd place