ICSharpCode.TextEditor设置选择的文本

    翻遍了ICSharpCode.TextEditor源码,居然没找到选择指定文本的现成的方法,可能我还不熟悉源码或运气不好没找到相关方法,只好自己动手了。
  
            //设置选择的文本。
            Point start = this.CurrentTextEditor.Document.OffsetToPosition(offset);
            Point end 
= this.CurrentTextEditor.Document.OffsetToPosition(offset + length);
            
this.CurrentTextEditor.ActiveTextAreaControl.SelectionManager.SetSelection(new DefaultSelection(this.CurrentTextEditor.Document, start, end));

            
//滚动到选择的位置。
            this.CurrentTextEditor.ActiveTextAreaControl.Caret.Position = end;
            
this.CurrentTextEditor.ActiveTextAreaControl.TextArea.ScrollToCaret();           

    注释已经很详细了,希望对有需要的人有所帮助。如果哪位同志知道ICSharpCode.TextEditor有这个功能麻烦在下面留个言,谢了!
    已修改,多谢  谢方 同志!
posted @ 2009-09-29 13:37  有容乃大  阅读(3685)  评论(2编辑  收藏  举报