Created
August 17, 2018 09:40
-
-
Save bjoerntx/daba6b5e439761c54ae0415103d18f72 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void setLineNumbering() | |
{ | |
textControl1.Refresh(); | |
Graphics g = textControl1.CreateGraphics(); | |
// iterates all lines | |
foreach (TXTextControl.Line line in textControl1.Lines) | |
{ | |
// left position of current line minus offset | |
// so that the line number is displayed next to the current line | |
int left = line.TextBounds.X - LINE_START_OFFSET; | |
//top position of the current line | |
int top = line.TextBounds.Top; | |
//converts the positon of the current line to client coordinates | |
Point p = textControl1.DocumentToClient(new Point(left, top)); | |
PointF pos = new PointF(p.X , p.Y); | |
//draws line number to the specified position | |
g.DrawString(line.Number.ToString() + ":", | |
new Font(textControl1.Font.Name, textControl1.Font.Size), | |
LINE_COLOR, pos); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment