public bool SetCaretOffset(int offset) { if (offset < 0) { return(false); } SWF.Document document = Document; int curPos = 0; SWF.Line line = null; for (int i = 1; i <= document.Lines; i++) { line = document.GetLine(i); int length = line.Text.ToString().Length; if (curPos + length >= offset) { document.PositionCaret(line, offset - curPos); return(true); } curPos += length; } return(false); }