No, you're not developing "notepad" application. Notepad already exists and is so rudimentary that, yes, a development of some text editor still makes some sense.
You can solve this problem like that:
internal void InquireCaretPosition(out Position line, out Position column) {
line = 0; column = 0;
int caret = this.CaretIndex;
int iLine = this.GetLineIndexFromCharacterIndex(caret);
if (iLine < 0) iLine = 0;
line = iLine;
int firstChar = this.GetCharacterIndexFromLineIndex(iLine);
if (firstChar < 0) firstChar = 0;
column = caret - firstChar;
}
This code should be written in class inheriting from
TextBox
.
Another problem: on what events to show the caret position in the status bar?
1) Overridden method
OnSelectionChanged
;
2) When your text box control instance is first shown;
3) If you have more then one text box controls; when you select/show one of them.
If I'm not much mistaken, it will cover all cases.
—SA