简体   繁体   English

如何在AvalonEdit中以编程方式设置代码选择?

[英]How to set the code selection programatically in AvalonEdit?

I'm using AvalonEdit in a Microsoft Surface application. 我在Microsoft Surface应用程序中使用AvalonEdit。 Since the Contacts are handled a little bit different there than in a normal WPF application, I want to set the code selection programatically. 由于联系人的处理方式与普通的WPF应用程序略有不同,我想以编程方式设置代码选择。

By code selection I mean this part of the code whichs background is changed if the user select it with the mouse. 通过代码选择我的意思是代码的这部分,如果用户用鼠标选择它,背景就会改变。

I now the DocumentLine or the VisualLine where the selection should start and where it should end. 我现在是DocumentLine或VisualLine,选择应该从哪里开始,应该在哪里结束。 But how can I now make this selection? 但是我现在怎么做这个选择呢?

this.Editor is AvalonEdit object, selectionStart is offset relative to the start of the text being edited. this.EditorAvalonEdit对象, selectionStart是相对于正在编辑的文本的开头的偏移量。

        this.Editor.SelectionStart = selectionStart;
        this.Editor.SelectionEnd = selectionStart + selectionLength;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM