I’m planning a C# app where some rather large strings will be displayed in scrollable/resizeable textboxes.
When the user closes the app and returns later, I’d like to redisplay these strings from the point they were displayed on lostFocus.
Is there a way to get the index, within the full text, of the first char that is displayed in a textBox?
These two should help you get the caret position. Get the caret position before you close your application, and then set it back using the
SelectionStartproperty:EDIT:
This works, just tested, as I said, it is important to use
SelectionStartproperty andScrollToCaret()method. You will have to get the index of the char that is first visible, for this you should useGetCharIndexFromPosition()method from theTextBox: