skip navigation
  • Product Bundles

    DevCraft

    All Telerik .NET tools and Kendo UI JavaScript components in one package. Now enhanced with:

    • NEW: Design Kits for Figma
    • Online Training
    • Document Processing Library
    • Embedded Reporting for web and desktop

    Web

    Kendo UI UI for Angular UI for Vue UI for jQuery KendoReact UI for Blazor UI for ASP.NET Core UI for ASP.NET MVC UI for ASP.NET AJAX

    Mobile

    UI for .NET MAUI

    Document Management

    Telerik Document Processing

    Desktop

    UI for .NET MAUI UI for WinUI UI for WinForms UI for WPF

    Reporting

    Telerik Reporting Telerik Report Server

    Testing & Mocking

    Test Studio Telerik JustMock

    CMS

    Sitefinity

    AI Productivity Tools

    AI Coding Assistants

    UI/UX Tools

    ThemeBuilder Design System Kit Templates and Building Blocks

    Debugging

    Fiddler Fiddler Everywhere Fiddler Classic Fiddler Everywhere Reporter FiddlerCore

    Free Tools

    KendoReact Free VB.NET to C# Converter Testing Framework
    View all products
  • Overview
  • Demos
    • What's New
    • Roadmap
    • Release History
  • Support and Learning

    • Support and Learning Hub
    • First Steps
    • Docs
    • Demos
    • Virtual Classroom
    • Forums
    • Videos
    • Blogs
    • Accessibility
    • Submit a Ticket

    Productivity and Design Tools

    • Visual Studio Extensions
    • Visual Studio Templates
    • Embedded Reporting
  • Pricing
  • Shopping cart
    • Account Overview
    • Your Licenses
    • Downloads
    • Support Center
    • Forum Profile
    • Payment Methods
    • Edit Profile
    • Log out
  • Login
  • Contact Us
  • Try now

Class DocumentSelection

Represents a selection in a RadDocument.

Inheritance
System.Object
DocumentSelection
Namespace: Telerik.Windows.Documents.Selection
Assembly: Telerik.Windows.Controls.RichTextBox.dll

Syntax

public class DocumentSelection : Object

Constructors

DocumentSelection(RadDocument)

Creates an instance of the DocumentSelection class.

Declaration
public DocumentSelection(RadDocument document)
Parameters
RadDocument document

A RadDocument instance which the selection will be associated to.

Properties

CanGetSelectedBoxes

Gets a value indicating whether the selected boxes can be enumerated correctly. This method can return false when the selection is not valid during specific operation when the document is being edited.

Declaration
public bool CanGetSelectedBoxes { get; }
Property Value
System.Boolean

IsEmpty

Gets a value determining whether the selection is empty.

Declaration
public bool IsEmpty { get; }
Property Value
System.Boolean

Ranges

Gets a collection of all SelectionRange instances in the selection.

Declaration
public SelectionRangeCollection Ranges { get; }
Property Value
SelectionRangeCollection

Methods

AddDocumentElementToSelection(DocumentElement)

Adds a specified document element to the existing selection.

Declaration
public void AddDocumentElementToSelection(DocumentElement documentElement)
Parameters
DocumentElement documentElement

The document element that should be added to the selection.

AddParagraphToSelection(Paragraph)

Adds a paragraph to the existing selection.

Declaration
public void AddParagraphToSelection(Paragraph paragraph)
Parameters
Paragraph paragraph

The paragraph that should be added to the selection.

AddSelectionEnd(DocumentPosition)

Finishes the started SelectionRange by setting its end at the specified position.

This method finishes a range started using AddSelectionStart(DocumentPosition) or SetSelectionStart(DocumentPosition).

Declaration
public void AddSelectionEnd(DocumentPosition position)
Parameters
DocumentPosition position

The end position.

AddSelectionStart(DocumentPosition)

Begins a new SelectionRange starting at the specified position.

This method starts the creation of a range, which should be finished with AddSelectionEnd(DocumentPosition).

Declaration
public void AddSelectionStart(DocumentPosition position)
Parameters
DocumentPosition position

The start position.

AddTableCellToSelection(TableCell)

Adds a table cell to the existing selection.

Declaration
public void AddTableCellToSelection(TableCell tableCell)
Parameters
TableCell tableCell

The cell that should be added to the selection.

AnchorSelectionPositions()

Declaration
public void AnchorSelectionPositions()

BeginUpdate()

Declaration
public void BeginUpdate()

Clear()

Clears the selection.

Declaration
public void Clear()

ContainsAnnotationMarkersOfType<T>()

Determines whether the selection contains annotation markers of type T.

Declaration
public bool ContainsAnnotationMarkersOfType<T>()
    where T : AnnotationMarkerBase
Returns
System.Boolean

True if the selection contains annotation markers of the specified type. Otherwise, false.

Type Parameters
T

CopySelectedDocumentElements(Boolean)

Copies all selected document elements to a DocumentFragment instance.

Declaration
public DocumentFragment CopySelectedDocumentElements(bool expandPartialRevisionRanges = false)
Parameters
System.Boolean expandPartialRevisionRanges

Determines whether the partially selected revision ranges should be preserved by creating pairs for them.

Returns
DocumentFragment

A DocumentFragment object containing the copied elements.

CopySelectedDocumentElements(SelectionRange)

Declaration
public static DocumentFragment CopySelectedDocumentElements(SelectionRange range)
Parameters
SelectionRange range

Returns
DocumentFragment

CreateDocumentFromSelection(Boolean)

Creates a new document from the selected elements.

Declaration
public RadDocument CreateDocumentFromSelection(bool replaceFieldsWithResults = false)
Parameters
System.Boolean replaceFieldsWithResults

Determines whether the fields in the selection should be replaced with their result values.

Returns
RadDocument

A RadDocument instance containing the elements from the selection.

EndUpdate()

Declaration
public void EndUpdate()

GetAnnotationMarkersOfType<T>()

Gets all annotation markers of type T in the selection.

Declaration
public IEnumerable<T> GetAnnotationMarkersOfType<T>()
    where T : AnnotationMarkerBase
Returns
System.Collections.Generic.IEnumerable<T>

A collection containing the annotation markers of type T in the selection.

Type Parameters
T

GetFullSelectionGeometry()

Gets a System.Windows.Media.Geometry instance describing the form of the selection.

Declaration
public Geometry GetFullSelectionGeometry()
Returns
System.Windows.Media.Geometry

A System.Windows.Media.Geometry instance describing the form of the selection.

GetSelectedBoxes()

Enumerates through all inline layout boxes included in the selected ranges.

Declaration
public IEnumerable<InlineLayoutBox> GetSelectedBoxes()
Returns
System.Collections.Generic.IEnumerable<InlineLayoutBox>

A collection of inline layout boxes.

GetSelectedBoxes<T>()

Enumerates through all inline layout boxes of type T included in the selected ranges.

Declaration
public IEnumerable<T> GetSelectedBoxes<T>()
    where T : InlineLayoutBox
Returns
System.Collections.Generic.IEnumerable<T>

A collection of inline layout boxes of type T.

Type Parameters
T

GetSelectedParagraphs()

Gets the paragraphs included in the selection.

Declaration
public IEnumerable<Paragraph> GetSelectedParagraphs()
Returns
System.Collections.Generic.IEnumerable<Paragraph>

A collection containing the paragraphs in the selection.

GetSelectedSingleInline()

Gets the selected Inline if it is the only inline selected, otherwise returns null.

For example, it is suitable to check if only a ImageInline is selected.

Declaration
public Inline GetSelectedSingleInline()
Returns
Inline

Returns the selected Inline if it is the only inline selected, otherwise returns null.

GetSelectedSingleShape()

Gets the selected shape inline if it is the only inline selected, otherwise returns null.

Declaration
public ShapeInline GetSelectedSingleShape()
Returns
ShapeInline

GetSelectedText()

Gets the selected text.

Declaration
public string GetSelectedText()
Returns
System.String

The text of the selection.

GetSelectedText(Boolean)

Gets the selected text.

Declaration
public string GetSelectedText(bool includeListsText)
Parameters
System.Boolean includeListsText

If set to true, the result will include the bullet or numbering characters in case a paragraph is in a list.

Returns
System.String

The text of the selection.

GetVisibleSelectionGeometry(RectangleF)

Gets a System.Windows.Media.Geometry instance describing the form of the selection visible in the visibleRectangle.

Declaration
public Geometry GetVisibleSelectionGeometry(RectangleF visibleRectangle)
Parameters
RectangleF visibleRectangle

The rectangle used to clip the selection.

Returns
System.Windows.Media.Geometry

A System.Windows.Media.Geometry instance describing the form of the selection.

OnSelectionChanged()

Called after the selection is changed.

Declaration
protected virtual void OnSelectionChanged()

OnSelectionChanging()

Called before the selection is changed.

Declaration
protected virtual void OnSelectionChanging()

RemoveSelectionPositionsAnchor()

Declaration
public void RemoveSelectionPositionsAnchor()

SelectAll()

Selects all elements in the document.

Declaration
public void SelectAll()

SelectAnnotationRange(AnnotationRangeStart)

Selects annotation range including the AnnotationRangeStart and AnnotationRangeEnd elements.

Declaration
public void SelectAnnotationRange(AnnotationRangeStart annotationStart)
Parameters
AnnotationRangeStart annotationStart

The AnnotationRangeStart of the annotation.

SelectTableColumn(Table, Int32)

Creates a new selection containing all the cells at a specified table grid column index.

The table grid is the set of grid columns which define all of the shared vertical edges of the table.

Declaration
public void SelectTableColumn(Table table, int gridColumnIndex)
Parameters
Table table

The table containing the column that should be selected.

System.Int32 gridColumnIndex

The index of the table grid column that should be selected.

SelectTableColumn(TableCell)

Creates a new selection containing all the cells at the table grid column index of the specified table cell.

Declaration
public void SelectTableColumn(TableCell tableCell)
Parameters
TableCell tableCell

A cell from the column that should be selected.

SelectTableRow(TableRow)

Creates a new selection containing the specific table row.

Declaration
public void SelectTableRow(TableRow tableRow)
Parameters
TableRow tableRow

The table row that should be selected.

SetSelectionStart(DocumentPosition)

Empties the selection and begins a new SelectionRange starting at the specified position.

This method starts the creation of a range, which should be finished with AddSelectionEnd(DocumentPosition).

Declaration
public void SetSelectionStart(DocumentPosition position)
Parameters
DocumentPosition position

The start position.

ToString()

Gets the text from the selected document elements.

Declaration
public override string ToString()
Returns
System.String

A string containing the text in the selection.

Events

SelectionChanged

Occurs after the selection is changed.

Declaration
public event EventHandler SelectionChanged
Event Type
System.EventHandler

SelectionChanging

Occurs before the selection is changed.

Declaration
public event EventHandler SelectionChanging
Event Type
System.EventHandler

Extension Methods

CollectionExtensions.ToEnumerable<T>(T)
EnumerableExtensions.ToEnumerable<T>(T)
Getting Started
  • Install Now
  • Demos
  • SDK Samples Browser
  • Sample Applications
Support Resources
  • Code Library
  • Knowledge Base
  • MVVM Support
  • Videos
  • GitHub SDK Repository
Community
  • Forums
  • Blogs
  • XAML Feedback Portal
  • Document Processing Feedback Portal

Copyright © 2018 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.

Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.