Hi, Furqan
As long as I know, there is no such a method or command to directly find out the columns number and the rows number of the textbox. But, you can implement by yourself.
Your idea gonna be interesting
, so I deal with it for you as an example, and it works well:
int start = textBox1.SelectionStart;//record the position of the cursor in textbox
int column = 0, row;
for (row = 0; row < textBox1.Lines.Length; row++)
{
if (start < 0)
break;
else
column = start;
start -= textBox1.Lines[row].Length + 2;//each newline costs 2
}
column++;//columns begin with 1
You can put above code to the event SelectionChanged of RichTextBox, that is raised when the caret is changing.
Hope it helps