在ICSharpCode文本编辑器中选择文本
问题描述:
我想在ICSharpCode TextEditor中选择文本行。以及使文本框转到特定的行。该应用程序是在C#中使用VS 2010构建的Windows窗体应用程序。在ICSharpCode文本编辑器中选择文本
我使用文本编辑器的原因是对代码高亮和行号等
我真的没有使用Windows窗体所以任何帮助,将不胜感激太多的经验。我的代码如下:
textEditorControl.Text = "long file string with line breaks";
textEditorControl.VRulerRow = 10; //Example row selection
答
下面是如何选择使用文本编辑器的文本包含的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;
我假设,通过“做文本去到特定的行“你的意思是将光标移动到该行。上面例子中的最后一行代码告诉你如何做到这一点。
谢谢马特,感谢帮助。 – Steve 2010-08-16 09:40:27