以下是如何使用 SharpDevelop 3.2 附带的文本编辑器选择文本的示例:
// Two lines of text.
textEditorControl.Text =
"First\r\n" +
"Second\r\n";
// Start of selection - columns and lines are zero based.
int startCol = 0;
int startLine = 1;
TextLocation start = new TextLocation(startCol, startLine);
// End of selection.
int endCol = 6;
int endLine = 1;
TextLocation end = new TextLocation(endCol, endLine);
// Select the second line.
textEditorControl.ActiveTextAreaControl.SelectionManager.SetSelection(start, end);
// Move cursor to end of selection.
textEditorControl.ActiveTextAreaControl.Caret.Position = end;
我假设“使文本框转到特定行”是指将光标移动到该行。上面示例中的最后一行代码向您展示了如何做到这一点。