Class SelectionAdv
Represents the SelectionAdv class.
Inheritance
Namespace: Syncfusion.UI.Xaml.RichTextBoxAdv
Assembly: Syncfusion.SfRichTextBoxAdv.UWP.dll
Syntax
public class SelectionAdv : DependencyObject
Constructors
SelectionAdv()
Initializes the new instance of the SelectionAdv class.
Declaration
public SelectionAdv()
Properties
CellFormat
Declaration
public SelectionCellFormat CellFormat { get; }
Property Value
Type |
---|
SelectionCellFormat |
CharacterFormat
Gets the SelectionCharacterFormat of the SelectionAdv.
Declaration
public SelectionCharacterFormat CharacterFormat { get; }
Property Value
Type | Description |
---|---|
SelectionCharacterFormat | The SelectionCharacterFormat of the SelectionAdv. |
EditingContext
Gets the EditingContext.
Declaration
public EditingContext EditingContext { get; }
Property Value
Type |
---|
EditingContext |
End
Gets the end TextPosition of the SelectionAdv.
Declaration
public TextPosition End { get; }
Property Value
Type | Description |
---|---|
TextPosition | The end TextPosition of the SelectionAdv. |
IsEmpty
Gets a value indicating whether the Start
and End
of the SelectionAdv denotes the same TextPosition.
Declaration
public bool IsEmpty { get; }
Property Value
Type | Description |
---|---|
System.Boolean | Returns True, if the |
ParagraphFormat
Gets the SelectionParagraphFormat of the SelectionAdv.
Declaration
public SelectionParagraphFormat ParagraphFormat { get; }
Property Value
Type | Description |
---|---|
SelectionParagraphFormat | The SelectionParagraphFormat of the SelectionAdv. |
RowFormat
Gets the selection Row format.
Declaration
public SelectionRowFormat RowFormat { get; }
Property Value
Type | Description |
---|---|
SelectionRowFormat | The selection Row format. |
SectionFormat
Gets the SelectionSectionFormat of the SelectionAdv.
Declaration
public SelectionSectionFormat SectionFormat { get; }
Property Value
Type | Description |
---|---|
SelectionSectionFormat | The SelectionSectionFormat of the SelectionAdv. |
SelectionRanges
Gets the SelectionRangeCollection of the SelectionAdv.
Declaration
public SelectionRangeCollection SelectionRanges { get; }
Property Value
Type | Description |
---|---|
SelectionRangeCollection | The SelectionRangeCollection of the SelectionAdv. |
Start
Gets the start TextPosition of the SelectionAdv.
Declaration
public TextPosition Start { get; }
Property Value
Type | Description |
---|---|
TextPosition | The start TextPosition of the SelectionAdv. |
TableFormat
Gets the SelectionTableFormat of the SelectionAdv.
Declaration
public SelectionTableFormat TableFormat { get; }
Property Value
Type | Description |
---|---|
SelectionTableFormat | The SelectionTableFormat of the SelectionAdv. |
Text
Gets the text of the SelectionAdv.
Declaration
public string Text { get; }
Property Value
Type | Description |
---|---|
System.String | The text of the SelectionAdv. |
Methods
Delete()
Deletes the selected content in SfRichTextBoxAdv control
Declaration
public bool Delete()
Returns
Type | Description |
---|---|
System.Boolean | Returns true if the selected content is deleted. Otherwise false |
Remarks
This method is valid only when the selection is non-empty. It deletes the selected content, like Delete key. For example, when some cells of a table or an entire table is selected it deletes only the cell contents.
InsertBreak(BreakType)
Inserts the specified BreakType at this SelectionAdv.
Declaration
public void InsertBreak(BreakType breakType)
Parameters
Type | Name | Description |
---|---|---|
BreakType | breakType |
Examples
The following code example demonstrates how to insert the page break at the current selection.
<RichTextBoxAdv:SfRichTextBoxAdv x:Name="richTextBoxAdv"/>
public void InsertPageBreakAtSelection()
{
// Inserts the specified break type at current selection position.
// If the current selection is not empty, removes the selected contents first and then inserts the break.
richTextBoxAdv.Selection.InsertBreak(BreakType.PageBreak);
}
Public Sub InsertPageBreakAtSelection()
' Inserts the specified break type at current selection position.
' If the current selection is not empty, removes the selected contents first and then inserts the break.
richTextBoxAdv.Selection.InsertBreak(BreakType.PageBreak)
End Sub
InsertHyperlink(String, String, String)
Inserts the specified hyperlink at this SelectionAdv.
Declaration
public void InsertHyperlink(string url, string displayText, string screenTip)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | The address (for example, a file name or URL) of the specified hyperlink. |
System.String | displayText | The display text of the specified hyperlink. |
System.String | screenTip | The text that appears as a ScreenTip, when you hovered mouse pointer over the hyperlink. |
Examples
The following code example demonstrates how to insert the specified hyperlink at the current selection.
<RichTextBoxAdv:SfRichTextBoxAdv x:Name="richTextBoxAdv"/>
public void InsertHyperlinkAtSelection()
{
// Inserts the specified hyperlink at current selection position.
// If the current selection is not empty, removes the selected contents first and then inserts the hyperlink.
richTextBoxAdv.Selection.InsertHyperlink("www.google.com", "click here", "google");
}
Public Sub InsertHyperlinkAtSelection()
' Inserts the specified hyperlink at current selection position.
' If the current selection is not empty, removes the selected contents first and then inserts the hyperlink.
richTextBoxAdv.Selection.InsertHyperlink("www.google.com", "click here", "google")
End Sub
InsertHyperlink(String, String, String, String)
Inserts the specified hyperlink at this SelectionAdv.
Declaration
public void InsertHyperlink(string url, string displayText, string screenTip, string targetFrame)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | The address (for example, a file name or URL) of the specified hyperlink. |
System.String | displayText | The display text of the specified hyperlink. |
System.String | screenTip | The text that appears as a ScreenTip, when you hovered mouse pointer over the hyperlink. |
System.String | targetFrame | The name of the frame or window in which to load the hyperlink. |
Remarks
The targetFrame
parameter takes any of the below listed values or custom name for the frame.
- _blankOpens the linked document in a new window or tab.
- _selfOpens the linked document in the same frame (this is browser default).
- _parentOpens the linked document in the parent frame.
- _topOpens the linked document in the full body of the window.
Examples
The following code example demonstrates how to insert the specified hyperlink at the current selection with target.
<RichTextBoxAdv:SfRichTextBoxAdv x:Name="richTextBoxAdv"/>
public void InsertHyperlinkAtSelection()
{
// Inserts the specified hyperlink at current selection position.
// If the current selection is not empty, removes the selected contents first and then inserts the hyperlink.
richTextBoxAdv.Selection.InsertHyperlink("www.google.com", "click here", "google", "_blank");
}
Public Sub InsertHyperlinkAtSelection()
' Inserts the specified hyperlink at current selection position.
' If the current selection is not empty, removes the selected contents first and then inserts the hyperlink.
richTextBoxAdv.Selection.InsertHyperlink("www.google.com", "click here", "google", "_blank")
End Sub
InsertPicture(Object)
Inserts the specified picture object at this SelectionAdv. The object can be a Windows.Storage.StorageFile, System.IO.Stream, byte array or file uri string.
Declaration
public void InsertPicture(object picture)
Parameters
Type | Name | Description |
---|---|---|
System.Object | picture | The picture object to be inserted. |
Examples
The following code example demonstrates how to insert the picture at the current selection.
<RichTextBoxAdv:SfRichTextBoxAdv x:Name="richTextBoxAdv"/>
public void InsertPictureAtSelection(Stream stream)
{
// Inserts the specified picture at current selection position.
// If the current selection is not empty, removes the selected contents first and then inserts the picture.
richTextBoxAdv.Selection.InsertPicture(stream);
}
Public Sub InsertPictureAtSelection(Stream stream)
' Inserts the specified picture at current selection position.
' If the current selection is not empty, removes the selected contents first and then inserts the picture.
richTextBoxAdv.Selection.InsertPicture(stream)
End Sub
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Picture cannot be null. |
InsertText(String)
Inserts the specified System.String at this SelectionAdv.
Declaration
public void InsertText(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to be inserted. |
Examples
The following code example demonstrates how to insert the specified text at the current selection.
<RichTextBoxAdv:SfRichTextBoxAdv x:Name="richTextBoxAdv"/>
public void InsertTextAtSelection()
{
// Inserts the specified text at current selection position.
// If the current selection is not empty, removes the selected contents first and then inserts the text.
richTextBoxAdv.Selection.InsertText("Hello world");
}
Public Sub InsertTextAtSelection()
' Inserts the specified text at current selection position.
' If the current selection is not empty, removes the selected contents first and then inserts the text.
richTextBoxAdv.Selection.InsertText("Hello world")
End Sub
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Text cannot be null. |
InsertUIContainer(UIElement, Double, Double)
Inserts the specified Windows.UI.Xaml.UIElement at this SelectionAdv.
Declaration
public void InsertUIContainer(UIElement UIElement, double width, double height)
Parameters
Type | Name | Description |
---|---|---|
Windows.UI.Xaml.UIElement | UIElement | The UIElement to insert. |
System.Double | width | The display width of the UIElement. |
System.Double | height | The display height of the UIElement. |
Examples
The following code example demonstrates how to insert the Windows.UI.Xaml.UIElement at the current selection.
<RichTextBoxAdv:SfRichTextBoxAdv x:Name="richTextBoxAdv"/>
public void InsertUIElementAtSelection()
{
// Inserts the specified button control at current selection position.
// If the current selection is not empty, removes the selected contents first and then inserts the button.
Button button = new Button();
button.Content = "Click Me!";
richTextBoxAdv.Selection.InsertUIContainer(button, 30, 30);
}
Public Sub InsertUIElementAtSelection()
' Inserts the specified button control at current selection position.
' If the current selection is not empty, removes the selected contents first and then inserts the button.
Dim button As Button = New Button()
button.Content = "Click Me!"
richTextBoxAdv.Selection.InsertUIContainer(button, 30, 30)
End Sub
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | UIElement cannot be null. |
System.ArgumentOutOfRangeException | Width should not be negative or infinity value. |
System.ArgumentOutOfRangeException | Height should not be negative or infinity value. |
Select(TextPosition, TextPosition)
Selects the specified start TextPosition and end TextPosition.
Declaration
public void Select(TextPosition startPosition, TextPosition endPosition)
Parameters
Type | Name | Description |
---|---|---|
TextPosition | startPosition | The TextPosition instance that denotes the start position of the SelectionAdv. |
TextPosition | endPosition | The TextPosition instance that denotes the end position of the SelectionAdv. |
Examples
The following code example demonstrates how to select the specified start and end position.
<RichTextBoxAdv:SfRichTextBoxAdv x:Name="richTextBoxAdv"/>
public void SelectContents()
{
// 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);
// Selects the text positions in reverse direction.
// richTextBoxAdv.Selection.Select(endPosition, startPosition);
// To make an empty selection at the specific text position.
// richTextBoxAdv.Selection.Select(startPosition, startPosition);
}
Public Sub SelectContents()
' 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)
' Selects the text positions in reverse direction.
' richTextBoxAdv.Selection.Select(endPosition, startPosition)
' To make an empty selection at the specific text position.
' richTextBoxAdv.Selection.Select(startPosition, startPosition)
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. |