Search code examples
c#.nettextboxtext-editoricsharpcode

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


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.


Solution

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