views:

58

answers:

1

Hi all,

I am trying to select lines of text in a ICSharpCode TextEditor. As well as make the textbox go to the specific row. The application is windows form app built in VS 2010 in C#.

The reason I am using the text editor is for the code highlighting and line numbers etc.

I dont really have too much experience using windows forms so any help would be appreciated. The Code I have is as follows:

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

Here is an example of how to select text with the Text Editor included with 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;

I am assuming that by "make the textbox go to the specific row" you mean move the cursor to that row. The last line of code in the example above shows you how to do that.

Matt Ward
Thanks Matt, appreciate the help.
Steve