Class
DocumentSelection

Represents a selection in a RadDocument.

Definition

Namespace:Telerik.Windows.Documents.Selection

Assembly:Telerik.Windows.Controls.RichTextBox.dll

Syntax:

cs-api-definition
public class DocumentSelection

Inheritance: objectDocumentSelection

Constructors

DocumentSelection(RadDocument)

Creates an instance of the DocumentSelection class.

Declaration

cs-api-definition
public DocumentSelection(RadDocument document)

Parameters

document

RadDocument

A RadDocument instance which the selection will be associated to.

Properties

IsEmpty

Gets a value determining whether the selection is empty.

Declaration

cs-api-definition
public bool IsEmpty { get; }

Property Value

bool

Ranges

Gets a collection of all SelectionRange instances in the selection.

Declaration

cs-api-definition
public SelectionRangeCollection Ranges { get; }

Property Value

SelectionRangeCollection

Methods

AddDocumentElementToSelection(DocumentElement)

Adds a specified document element to the existing selection.

Declaration

cs-api-definition
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

cs-api-definition
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

cs-api-definition
public void AddSelectionEnd(DocumentPosition position)

Parameters

position

DocumentPosition

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

cs-api-definition
public void AddSelectionStart(DocumentPosition position)

Parameters

position

DocumentPosition

The start position.

AddTableCellToSelection(TableCell)

Adds a table cell to the existing selection.

Declaration

cs-api-definition
public void AddTableCellToSelection(TableCell tableCell)

Parameters

tableCell

TableCell

The cell that should be added to the selection.

Clear()

Clears the selection.

Declaration

cs-api-definition
public void Clear()

ContainsAnnotationMarkersOfType<T>()

Determines whether the selection contains annotation markers of type T.

Declaration

cs-api-definition
public bool ContainsAnnotationMarkersOfType<T>() where T : AnnotationMarkerBase

Returns

bool

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

CopySelectedDocumentElements(bool)

Copies all selected document elements to a DocumentFragment instance.

Declaration

cs-api-definition
public DocumentFragment CopySelectedDocumentElements(bool expandPartialRevisionRanges = false)

Parameters

expandPartialRevisionRanges

bool

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

Returns

DocumentFragment

A DocumentFragment object containing the copied elements.

CreateDocumentFromSelection(bool)

Creates a new document from the selected elements.

Declaration

cs-api-definition
public RadDocument CreateDocumentFromSelection(bool replaceFieldsWithResults = false)

Parameters

replaceFieldsWithResults

bool

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.

GetAnnotationMarkersOfType<T>()

Gets all annotation markers of type T in the selection.

Declaration

cs-api-definition
public IEnumerable<T> GetAnnotationMarkersOfType<T>() where T : AnnotationMarkerBase

Returns

IEnumerable<T>

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

GetFullSelectionGeometry()

Gets a Geometry instance describing the form of the selection.

Declaration

cs-api-definition
public Geometry GetFullSelectionGeometry()

Returns

Geometry

A Geometry instance describing the form of the selection.

GetSelectedBoxes()

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

Declaration

cs-api-definition
public IEnumerable<InlineLayoutBox> GetSelectedBoxes()

Returns

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

cs-api-definition
public IEnumerable<T> GetSelectedBoxes<T>() where T : InlineLayoutBox

Returns

IEnumerable<T>

A collection of inline layout boxes of type T.

GetSelectedParagraphs()

Gets the paragraphs included in the selection.

Declaration

cs-api-definition
public IEnumerable<Paragraph> GetSelectedParagraphs()

Returns

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

cs-api-definition
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

cs-api-definition
public ShapeInline GetSelectedSingleShape()

Returns

ShapeInline

GetSelectedText()

Gets the selected text.

Declaration

cs-api-definition
public string GetSelectedText()

Returns

string

The text of the selection.

GetSelectedText(bool)

Gets the selected text.

Declaration

cs-api-definition
public string GetSelectedText(bool includeListsText)

Parameters

includeListsText

bool

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

Returns

string

The text of the selection.

GetVisibleSelectionGeometry(RectangleF)

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

Declaration

cs-api-definition
public Geometry GetVisibleSelectionGeometry(RectangleF visibleRectangle)

Parameters

visibleRectangle

RectangleF

The rectangle used to clip the selection.

Returns

Geometry

A Geometry instance describing the form of the selection.

OnSelectionChanged()

Called after the selection is changed.

Declaration

cs-api-definition
protected virtual void OnSelectionChanged()

OnSelectionChanging()

Called before the selection is changed.

Declaration

cs-api-definition
protected virtual void OnSelectionChanging()

SelectAll()

Selects all elements in the document.

Declaration

cs-api-definition
public void SelectAll()

SelectAnnotationRange(AnnotationRangeStart)

Selects annotation range including the AnnotationRangeStart and AnnotationRangeEnd elements.

Declaration

cs-api-definition
public void SelectAnnotationRange(AnnotationRangeStart annotationStart)

Parameters

annotationStart

AnnotationRangeStart

The AnnotationRangeStart of the annotation.

SelectTableColumn(Table, int)

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

cs-api-definition
public void SelectTableColumn(Table table, int gridColumnIndex)

Parameters

table

Table

The table containing the column that should be selected.

gridColumnIndex

int

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

cs-api-definition
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

cs-api-definition
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

cs-api-definition
public void SetSelectionStart(DocumentPosition position)

Parameters

position

DocumentPosition

The start position.

ToString()

Gets the text from the selected document elements.

Declaration

cs-api-definition
public override string ToString()

Returns

string

A string containing the text in the selection.

Overrides object.ToString()

Events

SelectionChanged

Occurs after the selection is changed.

Declaration

cs-api-definition
public event EventHandler SelectionChanged

Event Value

EventHandler

SelectionChanging

Occurs before the selection is changed.

Declaration

cs-api-definition
public event EventHandler SelectionChanging

Event Value

EventHandler