public void GotoLine(int RowIndex)
{
if (RowIndex >= Document.Count)
RowIndex = Document.Count - 1;
if (RowIndex < 0)
RowIndex = 0;
Caret.Position.Y = RowIndex;
Caret.Position.X = 0;
Caret.CurrentRow.EnsureVisible();
ClearSelection();
ScrollIntoView();
Redraw();
}