Snippets from Resource File

SyntaxEditor for Windows Forms Forum

Posted 15 years ago by Sean Miller
Version: 4.0.0280
Avatar
I would like to create some snippets from a resource file so this is what I attempt to do:

Private Sub AddCodeSnippets()

Dim Document As New Xml.XmlDocument
Dim Xml As String = My.Resources.CodeSnippets
Document.LoadXml(Xml)

Dim Snippets() As CodeSnippet = CodeSnippet.LoadFromXml(Document)
Dim Folder As New CodeSnippetFolder("")

For Each Snippet As CodeSnippet In Snippets
Folder.CodeSnippets.Add(Snippet)
Next

DotNetResolver.CodeSnippetFolders.Add(Folder)

End Sub


In the Editor I add a Button to show the snippets and they do show, however when I select the snippet I get the following:

"A header-only code snippet 'For' was activated but no source file was specified. The code snippet cannot be activated unless its SourceFile property is set."

Is my approach above incorrect? I didn't specifiy a folder name in the constructor for the CodeSnippetFolder because it's a resource file.

Comments (1)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Sean,

You'd have to set CodeSnippet.IsHeaderOnly = false, and then in the CodeSnippetActivating event, be sure to set e.CodeText from your resource.


Actipro Software Support

The latest build of this product (v24.1.0) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.