VB version here.
This method is more efficient than basically anything else you can come up with because under the hood it calls the SendMessage API, so there is no string manipulation to slow things down.Put that in the SelectionChanged event handler of your RTB and it will show you your location without slowing your typing.CSharp Code:
int currentLineIndex = myRTB.GetLineFromCharIndex(myRTB.SelectionStart); int lastLineIndex = myRTB.GetLineFromCharIndex(myRTB.TextLength); int currentColumnIndex = myRTB.SelectionStart - myRTB.GetFirstCharIndexFromLine(currentLineIndex); this.label1.Text = string.Format("Line {0}/{1}, Column {2}", currentLineIndex + 1, lastLineIndex + 1, currentColumnIndex + 1);


Reply With Quote