Warm tip: This article is reproduced from stackoverflow.com, please click
.net c# text-editor textbox icsharpcode

How to Auto-Complete a tag with ICsharpCode.TextEditor component?

发布于 2020-05-09 17:13:38

I have added the ICSharpCode.TextEditor.dll component to my Visual Studio 2017 reference in my C# project. Next, i want to find out a way to Auto-complete a tag. I have provided a GIF image below on what i mean.

enter image description here

I have provided a code that i tried to debug with the component itself, but it doesn't work.

if (textEditorControl1.Text.Contains("<html>"))
        {
            textEditorControl1.ActiveTextAreaControl.SelectionManager.SelectedText("</html>");                
        }

The ICsharpCode.TextEditor component does not have the same property as a normal Textbox.

if (textBox2.Text.Contains("<html>"))
        {
            textBox2.SelectedText = "</html>";
        }

If i try debugging the TextBox version, i get the tag countless times until i get an unhandled System.StackOverflowException.

Questioner
RobinHannanJanssen
Viewed
21
RJay 2020-02-25 14:08

I found exactly what you're looking for here. The only thing is, that this is a working code for a normal TextBox.