3

ICSharpCodeTextEditorでテキストの行を選択しようとしています。また、テキストボックスを特定の行に移動させます。アプリケーションは、C#のVS2010で構築されたWindowsフォームアプリです。

私がテキストエディタを使用している理由は、コードの強調表示や行番号などのためです。

私はWindowsフォームの使用経験があまりないので、助けていただければ幸いです。私が持っているコードは次のとおりです。

textEditorControl.Text = "long file string with line breaks";
textEditorControl.VRulerRow = 10; //Example row selection
4

1 に答える 1

5

SharpDevelop3.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;

「テキストボックスを特定の行に移動させる」とは、カーソルをその行に移動することを意味すると思います。上記の例のコードの最後の行は、その方法を示しています。

于 2010-08-14T17:02:57.490 に答える