Table of Contents

Property Selection

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

Selection

Represents an object that implements ISelection interface. This object represents various properties and methods to manipulate text selection, such as copy, paste and drag selected text.

[TypeConverter(typeof(ExpandableObjectConverter))]
public virtual ISelection Selection { get; set; }

Property Value

ISelection

Examples

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

public partial class Form1 : Form
{
    private void Form1_Load(object sender, EventArgs e)
    {
        var syntaxEdit1 = new Alternet.Editor.SyntaxEdit(this.components);
        textSource.LoadFile("myfile.txt");
        syntaxEdit1.Selection.Options |= SelectionOptions.DrawBorder;
        syntaxEdit1.Selection.BackColor = System.Drawing.Color.LightBlue;
        syntaxEdit1.Selection.SelectionChanged += Selection_SelectionChanged;
    }

    private void Selection_SelectionChanged(object sender, EventArgs e)
    {
        System.Console.WriteLine(syntaxEdit1.Selection.SelectedText);
    }
}

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

Partial Public Class Form1
    Inherits Form

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
        Dim syntaxEdit1 = New Alternet.Editor.SyntaxEdit(Me.components)
        textSource.LoadFile("myfile.txt")
        syntaxEdit1.Selection.Options = syntaxEdit1.Selection.Options Or SelectionOptions.DrawBorder
        syntaxEdit1.Selection.BackColor = System.Drawing.Color.LightBlue
        AddHandler syntaxEdit1.Selection.SelectionChanged, New System.EventHandler(AddressOf Selection_SelectionChanged)
    End Sub

    Private Sub Selection_SelectionChanged(ByVal sender As Object, ByVal e As EventArgs)
        System.Console.WriteLine(syntaxEdit1.Selection.SelectedText)
    End Sub
End Class

Remarks

Use the ISelection property to control the appearance of selected text, such as the background color, and programmatically select and manipulate blocks of the text within the SyntaxEdit control.