I found an example, how to show the LineNumbers from a RichTextBox in Windows Forms.
http://www.codeproject.com/Articles/38858/Line-Numbers-for-RichText-Control
Here's a nice CodeProject article that shows a detailed approach to implementing line numbers and a handful of other nice code editing features in a TextBox control. If you don't care about how it's built, just download the sample file and use the included dll that contains the compiled control.