• HOME
  • PRODUCTS
  • DEMOS
  • BUY
  • BLOG
  • FORUM
  • DOCUMENTATION
  • ABOUT
  • FREE EVALUATION
Search Results for

    Show / Hide Table of Contents

    Selection Property

    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.

    Declaration
    public ISelection Selection { get; }
    Property Value
    Type Description
    ISelection
    Remarks

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

    Examples

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

    using System.Windows.Media;
    
    public partial class MainWindow : Window
    {
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var textEditor = new Alternet.Editor.Wpf.TextEditor();
            textSource.LoadFile("myfile.txt");
            textEditor.Selection.Options |= SelectionOptions.DrawBorder;
            textEditor.SelectionBrush = new SolidColorBrush(Colors.LightBlue);
            textEditor.Selection.SelectionChanged += Selection_SelectionChanged;
        }
    
        private void Selection_SelectionChanged(object sender, EventArgs e)
        {
            System.Console.WriteLine(textEditor.Selection.SelectedText);
        }
    }
    

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

    Imports System.Windows.Media
    Partial Public Class MainWindow
    
        Private Sub Window_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
            Dim textEditor = New Alternet.Editor.Wpf.TextEditor()
            textEditor.LoadFile("myfile.txt")
            textEditor.Selection.Options = textEditor.Selection.Options Or SelectionOptions.DrawBorder
            textEditor.SelectionBrush = New SolidColorBrush(Colors.LightBlue)
            AddHandler textEditor.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(textEditor.Selection.SelectedText)
        End Sub
    End Class
    
    In This Article
    Back to top Copyright AlterNET Software Download PDF