New to Telerik UI for WinFormsStart a free 30-day trial

Represents a selection in a RadDocument.

Definition

Namespace:Telerik.WinForms.Documents.Selection

Assembly:Telerik.WinControls.RichTextEditor.dll

Syntax:

C#
public class DocumentSelection

Inheritance: objectDocumentSelection

Constructors

Creates an instance of the DocumentSelection class.

C#
public DocumentSelection(RadDocument document)
Parameters:documentRadDocument

A RadDocument instance which the selection will be associated to.

Properties

Gets a value determining whether the selection is empty.

C#
public bool IsEmpty { get; }

Gets a collection of all SelectionRange instances in the selection.

C#
public SelectionRangeCollection Ranges { get; }

Methods

Adds a specified document element to the existing selection.

C#
public void AddDocumentElementToSelection(DocumentElement documentElement)
Parameters:documentElementDocumentElement

The document element that should be added to the selection.

Adds a paragraph to the existing selection.

C#
public void AddParagraphToSelection(Paragraph paragraph)
Parameters:paragraphParagraph

The paragraph that should be added to the selection.

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

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

C#
public void AddSelectionEnd(DocumentPosition position)
Parameters:positionDocumentPosition

The end position.

Begins a new SelectionRange starting at the specified position.

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

C#
public void AddSelectionStart(DocumentPosition position)
Parameters:positionDocumentPosition

The start position.

Adds a table cell to the existing selection.

C#
public void AddTableCellToSelection(TableCell tableCell)
Parameters:tableCellTableCell

The cell that should be added to the selection.

Clears the selection.

C#
public void Clear()

Determines whether the selection contains annotation markers of type T.

C#
public bool ContainsAnnotationMarkersOfType<T>() where T : AnnotationMarkerBase
Returns:

bool

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

Copies all selected document elements to a DocumentFragment instance.

C#
public DocumentFragment CopySelectedDocumentElements(bool expandPartialRevisionRanges = false)
Parameters:expandPartialRevisionRangesbool

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

Returns:

DocumentFragment

A DocumentFragment object containing the copied elements.

Creates a new document from the selected elements.

C#
public RadDocument CreateDocumentFromSelection(bool replaceFieldsWithResults = false)
Parameters:replaceFieldsWithResultsbool

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.

Gets all annotation markers of type T in the selection.

C#
public IEnumerable<T> GetAnnotationMarkersOfType<T>() where T : AnnotationMarkerBase
Returns:

IEnumerable<T>

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

Gets a Geometry instance describing the form of the selection.

C#
public Geometry GetFullSelectionGeometry()
Returns:

Geometry

A Geometry instance describing the form of the selection.

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

C#
public IEnumerable<InlineLayoutBox> GetSelectedBoxes()
Returns:

IEnumerable<InlineLayoutBox>

A collection of inline layout boxes.

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

C#
public IEnumerable<T> GetSelectedBoxes<T>() where T : InlineLayoutBox
Returns:

IEnumerable<T>

A collection of inline layout boxes of type T.

Gets the paragraphs included in the selection.

C#
public IEnumerable<Paragraph> GetSelectedParagraphs()
Returns:

IEnumerable<Paragraph>

A collection containing the paragraphs in the selection.

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.

C#
public Inline GetSelectedSingleInline()
Returns:

Inline

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

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

C#
public ShapeInline GetSelectedSingleShape()
Returns:

ShapeInline

Gets the selected text.

C#
public string GetSelectedText()
Returns:

string

The text of the selection.

Gets the selected text.

C#
public string GetSelectedText(bool includeListsText)
Parameters:includeListsTextbool

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.

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

C#
public Geometry GetVisibleSelectionGeometry(RectangleF visibleRectangle)
Parameters:visibleRectangleRectangleF

The rectangle used to clip the selection.

Returns:

Geometry

A Geometry instance describing the form of the selection.

Called after the selection is changed.

C#
protected virtual void OnSelectionChanged()

Called before the selection is changed.

C#
protected virtual void OnSelectionChanging()

Selects all elements in the document.

C#
public void SelectAll()

Selects annotation range including the AnnotationRangeStart and AnnotationRangeEnd elements.

C#
public void SelectAnnotationRange(AnnotationRangeStart annotationStart)
Parameters:annotationStartAnnotationRangeStart

The AnnotationRangeStart of the annotation.

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.

C#
public void SelectTableColumn(Table table, int gridColumnIndex)
Parameters:tableTable

The table containing the column that should be selected.

gridColumnIndexint

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

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

C#
public void SelectTableColumn(TableCell tableCell)
Parameters:tableCellTableCell

A cell from the column that should be selected.

Creates a new selection containing the specific table row.

C#
public void SelectTableRow(TableRow tableRow)
Parameters:tableRowTableRow

The table row that should be selected.

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).

C#
public void SetSelectionStart(DocumentPosition position)
Parameters:positionDocumentPosition

The start position.

Gets the text from the selected document elements.

C#
public override string ToString()
Returns:

string

A string containing the text in the selection.

Overrides: object.ToString()

Events

Occurs after the selection is changed.

C#
public event EventHandler SelectionChanged

Occurs before the selection is changed.

C#
public event EventHandler SelectionChanging