Search code examples
text-editorsyntax-highlightingicsharpcode

Using ICSharpCode.TextEditor on VB.NET


I've integrated ICSharpCode.TextEditor into VB.NET and it run smoothly without error. But, I cannot find in properties window the property to enable or select the syntax highlighting features as well as intellisense. I don't have any experience with ICSTE, so please help me. Thanks you.


Solution

  • Here is code from my project

    //Initialize HM
    HighlightingManager.Manager.AddSyntaxModeFileProvider(new FileSyntaxModeProvider(AppDomain.CurrentDomain.BaseDirectory));
    
    //Setup current Highlighter
    
    IHighlightingStrategy highlighter = HighlightingManager.Manager.FindHighlighter("SQL");
    txtQuery.Document.HighlightingStrategy = highlighter;
    

    Ensure that file SQL.xshd exists in AppDomain.CurrentDomain.BaseDirectory

    As for entellisense you should implement it mostly yourself using this code

    private void ShowCompletionWindow(ICompletionDataProvider completionDataProvider, char ch)
            {
    
                try
                {
                    codeCompletionWindow = CodeCompletionWindow.ShowCompletionWindow(
                        this,
                        codeEditorControl,
                        "<code>",
                        completionDataProvider,
                        ch);
                    if (codeCompletionWindow != null)
                    {
                        codeCompletionWindow.Closed += delegate
                                                        {
                                                            _blockKeys = false;
                                                        };
    
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }