Property CurrentSnippet
- Namespace
- Alternet.Editor.TextSource
- Assembly
- Alternet.Editor.v9.dll
CurrentSnippet
Gets or sets the current ICodeSnippetRange
object.
[Browsable(false)]
public virtual ICodeSnippetRange CurrentSnippet { get; set; }
Property Value
Examples
Here is how to use a CurrentSnippet 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.CurrentSnippet != null)
MessageBox.Show(textSource.CurrentSnippet.ID);
}
}
Here is how to use a CurrentSnippet 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.CurrentSnippet IsNot Nothing Then MessageBox.Show(textSource.CurrentSnippet.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 CurrentSnippet property will contain a ICodeSnippetRange object representing a selected code snippet literal.
The user can navigate between code snippet literals right after the code snippet is inserted by pressing the TAB key.