Table of Contents

Property CodeSnippets

Namespace
Alternet.Editor.TextSource
Assembly
Alternet.Editor.v9.dll

CodeSnippets

Gets or sets ICodeSnippetRangeList for Edit control.

[Browsable(false)]
public virtual ICodeSnippetRanges CodeSnippets { get; set; }

Property Value

ICodeSnippetRanges

Examples

Here is how to use a CodeSnippets in the C# code:

using System.Windows.Forms;

using Alternet.Editor;
using Alternet.Editor.TextSource;

public partial class Form1 : Form
{
    private TextSource textSource;
    private void Form1_Load(object sender, EventArgs e)
    {
        var syntaxEdit = new SyntaxEdit(this.components);
        textSource = new TextSource(this.components);
        textSource.LoadFile("myfile.txt");
        syntaxEdit.Source = this.textSource;
    }

    private void Button_Click(object sender, EventArgs e)
    {
        if ((textSource.CodeSnippets != null) && textSource.CodeSnippets.Count > 0)
            MessageBox.Show(textSource.CodeSnippets[0].ID);
    }
}

Here is how to use a CodeSnippets in the Visual Basic code:

Imports System.Windows.Forms
Imports Alternet.Editor
Imports Alternet.Editor.TextSource

Partial Public Class Form1
    Inherits Form

    Private textSource As TextSource

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
        Dim syntaxEdit = New SyntaxEdit(Me.components)
        textSource = New TextSource(Me.components)
        textSource.LoadFile("myfile.txt")
        syntaxEdit.Source = Me.textSource
    End Sub

    Private Sub Button_Click(ByVal sender As Object, ByVal e As EventArgs)
        If (textSource.CodeSnippets IsNot Nothing) AndAlso textSource.CodeSnippets.Count > 0 Then MessageBox.Show(textSource.CodeSnippets(0).ID)
    End Sub
End Class

Remarks

Code snippets are ready-made snippets of code you can quickly insert into the text. When the user selects a code snippet from the code snippet list (usually invoked by Ctrl + K + X key combination), the CodeSnippets property will contain a collection of ICodeSnippetRange objects, each one is representing a code snippet literal being inserted.