翻遍了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有这个功能麻烦在下面留个言,谢了!
    已修改,多谢   同志!

相关文章:

  • 2022-12-23
  • 2021-07-15
  • 2021-10-23
  • 2021-11-29
  • 2021-11-12
  • 2022-01-05
  • 2021-12-09
  • 2022-02-06
猜你喜欢
  • 2021-12-31
  • 2021-08-19
  • 2022-01-22
  • 2022-02-03
  • 2021-12-02
  • 2021-11-04
  • 2022-01-08
相关资源
相似解决方案