Class SelectionRangeCollection
Represents the SelectionRangeCollection class.
Inheritance
Namespace: Syncfusion.UI.Xaml.RichTextBoxAdv
Assembly: Syncfusion.SfRichTextBoxAdv.UWP.dll
Syntax
public class SelectionRangeCollection : Object
Properties
Count
Gets the number of SelectionRange instances actually contained in the SelectionRangeCollection.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 | The the number of SelectionRange instances actually contained in the SelectionRangeCollection. |
First
Gets the first SelectionRange instance from the SelectionRangeCollection.
Declaration
public SelectionRange First { get; }
Property Value
Type | Description |
---|---|
SelectionRange | If the SelectionRangeCollection is empty, returns null. Otherwise returns the first SelectionRange instance. |
Last
Gets the last SelectionRange instance from the SelectionRangeCollection.
Declaration
public SelectionRange Last { get; }
Property Value
Type | Description |
---|---|
SelectionRange | If the SelectionRangeCollection is empty, returns null. Otherwise returns the last SelectionRange instance. |
Methods
Add(TextPosition, TextPosition)
Adds the specified start TextPosition and end TextPosition as a SelectionRange instance to the SelectionRangeCollection.
Declaration
public void Add(TextPosition startPosition, TextPosition endPosition)
Parameters
Type | Name | Description |
---|---|---|
TextPosition | startPosition | The start TextPosition. |
TextPosition | endPosition | The end TextPosition. |
Examples
The following code example demonstrates how to add the specified start and end positions to the selection range collection.
<RichTextBoxAdv:SfRichTextBoxAdv x:Name="richTextBoxAdv"/>
public void AddSelection()
{
// Retrieves the position at the first paragraph start.
TextPosition startPosition = richTextBoxAdv.Document.GetTextPosition("0;0;0");
// Retrieves the position at offset = 20 in the first paragraph.
TextPosition endPosition = richTextBoxAdv.Document.GetTextPosition("0;0;20");
// Selects the text positions in forward direction.
richTextBoxAdv.Selection.Select(startPosition, endPosition);
// Retrieves the position at offset = 1 in the third paragraph start.
TextPosition secondStartPosition = richTextBoxAdv.Document.GetTextPosition("0;2;1");
// Retrieves the position at offset = 16 in the fifth paragraph.
TextPosition secondEndPosition = richTextBoxAdv.Document.GetTextPosition("0;4;16");
// Adds the second start position and second end position to the selection ranges.
richTextBoxAdv.Selection.SelectionRanges.Add(secondStartPosition, secondEndPosition);
}
Public Sub AddSelection()
' Retrieves the position at the first paragraph start.
Dim startPosition As TextPosition = richTextBoxAdv.Document.GetTextPosition("0;0;0")
' Retrieves the position at offset = 20 in the first paragraph.
Dim endPosition As TextPosition = richTextBoxAdv.Document.GetTextPosition("0;0;20")
' Selects the text positions in forward direction.
richTextBoxAdv.Selection.Select(startPosition, endPosition)
' Retrieves the position at offset = 1 in the third paragraph.
Dim secondStartPosition As TextPosition = richTextBoxAdv.Document.GetTextPosition("0;2;1")
' Retrieves the position at offset = 16 in the fifth paragraph.
Dim secondEndPosition As TextPosition = richTextBoxAdv.Document.GetTextPosition("0;4;16")
' Adds the second start position and second end position to the selection ranges.
richTextBoxAdv.Selection.SelectionRanges.Add(secondStartPosition, secondEndPosition)
End Sub
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | TextPosition cannot be null. |
System.ArgumentException | Invalid start TextPosition. |
System.ArgumentException | Invalid end TextPosition. |
System.ArgumentException | A text position within comment can be selected with another text position within the same comment only. |
See Also
Clear()
Removes all the SelectionRange instances from the SelectionRangeCollection.
Declaration
public void Clear()
Examples
The following code example demonstrates how to clear the selection range collection.
<RichTextBoxAdv:SfRichTextBoxAdv x:Name="richTextBoxAdv"/>
public void ClearSelection()
{
// Clears the selection ranges.
richTextBoxAdv.Selection.SelectionRanges.Clear();
}
Public Sub ClearSelection()
' Clears the selection ranges.
richTextBoxAdv.Selection.SelectionRanges.Clear()
End Sub
Contains(SelectionRange)
Determines whether the specified SelectionRange instance is contained in the SelectionRangeCollection.
Declaration
public bool Contains(SelectionRange selectionRange)
Parameters
Type | Name | Description |
---|---|---|
SelectionRange | selectionRange | The SelectionRange instance which needs to be determined whether exists in this collection. |
Returns
Type | Description |
---|---|
System.Boolean | Returns True, if the specified SelectionRange is contained in the SelectionRangeCollection. Otherwise returns False. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | SelectionRange cannot be null. |
Remove(SelectionRange)
Removes the specified SelectionRange from the SelectionRangeCollection.
Declaration
public bool Remove(SelectionRange selectionRange)
Parameters
Type | Name | Description |
---|---|---|
SelectionRange | selectionRange | The SelectionRange instance needed to be removed from the SelectionRangeCollection. |
Returns
Type | Description |
---|---|
System.Boolean | Returns True, if the specified SelectionRange is removed successfully from the SelectionRangeCollection. Otherwise returns False. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | SelectionRange cannot be null. |