how to display line numbers in text box

  • Thread starter Thread starter rammohan
  • Start date Start date
R

rammohan

i want to implement an option similar to line numbers
option in c# editor. how can i display line numbers on
left side in text box.how can i know the present cursor
location with respect to control.
 
Hi,
i want to implement an option similar to line numbers
option in c# editor. how can i display line numbers on
left side in text box.how can i know the present cursor
location with respect to control.

You can using this:

string fullText=textBox1.Text;
int linesInFullText=wholeText.Split('\n').Length;
string textToCursor=wholeText.Substring(0, textBox1.SelectionStart);
int currentLineNumber=(textToCursor.Split('\n').Length-1);

But i can not invent any good presentation of line numbers other
than e.g. ListBox on the left side of TextBox.

Regards

Marcin
 
Yeah,that's what i really want.
Display the line number in the first column is substitute.
 
Back
Top