How to get/set the Caret Position?
I'm working at a XML Editor with Search and GoToLine. Most parts are already implemented but i cannot find a way to set the Caret position for both.
Use property CurrentPosition for getting the current position. And call method GotoPosition to set the Caret to a specific a position.
With GoToPosition(LineNumber) the Caret gets set only to the character of the given number (For example if my text has 106 Lines and I want to do to Line 50 im in Line 2 and character 50)
Sorry I don't understand you. Method GotoPosition accepts the character position not a line number.
Yes but I want to set the Caret to a specific Line with my own GoToLine Dialog
You can look at Lines property which each of them has the Position and then use GoToPosition.
I thought:
MyScintilla.Lines[23].Goto();
or
MyScintilla.GotoPosition(MyScintilla.Lines[23].Position);
@Stumpii and @Aghlara are correct. If you want to get to a specific character on a specific line, do the math that would determine what position that is, e.g. line position start + offset.
However, I might suggest that you're making it unnecessarily hard for yourself. Why isn't your search/find dialog giving you the document position directly instead of the line+offset? If it did that you could pass the value straight to GoToPosition.