menu

UWP

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Interface ITextSelection - UWP API Reference | Syncfusion

    Show / Hide Table of Contents

    Interface ITextSelection

    Represent a selection of text inside paragraph.

    Namespace: Syncfusion.Presentation
    Assembly: Syncfusion.Presentation.UWP.dll
    Syntax
    public interface ITextSelection

    Properties

    Count

    Gets the number of text chunks in the ITextPart collection. Read-only.

    Declaration
    int Count { get; }
    Property Value
    Type Description
    System.Int32

    The count.

    Examples
    //Create a new presentation instance.
    IPresentation presentation = Presentation.Create();
    //Add the slide into the presentation
    ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
    // Add a text box to hold the list
    IShape textBoxShape = slide.AddTextBox(65, 140, 410, 270);
    // Add a new paragraph with a text
    IParagraph paragraph = textBoxShape.TextBody.AddParagraph("Hello World");
    ITextSelection textSelection = presentation.Find("World", false, false);
    int count = textSelection.Count;
    //Save the presentation
    presentation.Save("Output.pptx");
    //Close the presentation
    presentation.Close();
     'Creates a presentation.
     Dim presentation As IPresentation = Presentation.Create()
     'Add the slide into the presentation
     Dim slide As ISlide = presentation.Slides.Add(SlideLayoutType.Blank)
     'Add a text box to hold the list 
     Dim textBoxShape As IShape = slide.AddTextBox(65, 140, 410, 270)
     'Add a new paragraph with a text
     Dim paragraph As IParagraph = textBoxShape.TextBody.AddParagraph("Hello World")
     'Finds the text from the Presentation document
     Dim textSelection As ITextSelection = presentation.Find("World", False, False)
     'Gets the selected text from the text selections index
     Dim count As Integer = textSelection.Count
     presentation.Save("Output.pptx")
     presentation.Close()

    Item[Int32]

    Gets the string at the specified index from the ITextPart collection.

    Declaration
    string this[int index] { get; }
    Parameters
    Type Name Description
    System.Int32 index

    The zero-based index of the string to get.

    Property Value
    Type Description
    System.String

    The string at the specified collection.

    Examples
    //Create a new presentation instance.
    IPresentation presentation = Presentation.Create();
    //Add the slide into the presentation
    ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
    // Add a text box to hold the list
    IShape textBoxShape = slide.AddTextBox(65, 140, 410, 270);
    // Add a new paragraph with a text
    IParagraph paragraph = textBoxShape.TextBody.AddParagraph("Hello World");
    // Finds all the text from the Presentation document
    ITextSelection[] textSelections = presentation.FindAll("World", false, false);
    string text = textSelections[0].SelectedText;
    //Save the presentation
    presentation.Save("Output.pptx");
    //Close the presentation
    presentation.Close();
     'Creates a presentation.
     Dim presentation As IPresentation = Presentation.Create()
     'Add the slide into the presentation
     Dim slide As ISlide = presentation.Slides.Add(SlideLayoutType.Blank)
     'Add a text box to hold the list 
     Dim textBoxShape As IShape = slide.AddTextBox(65, 140, 410, 270)
     'Add a new paragraph with a text
     Dim paragraph As IParagraph = textBoxShape.TextBody.AddParagraph("Hello World")
     'Finds all the text from the Presentation document
     Dim textSelections As ITextSelection() = presentation.FindAll("World", False, False)
     'Gets the selected text from the text selections index
     Dim text As String = textSelections(0).SelectedText
     presentation.Save("Output.pptx")
     presentation.Close()

    SelectedText

    Gets the selected text. Read-only.

    Declaration
    string SelectedText { get; }
    Property Value
    Type Description
    System.String

    The string that represents the selected text.

    Examples
    //Create a new presentation instance.
    IPresentation presentation = Presentation.Create();
    //Add the slide into the presentation
    ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
    // Add a text box to hold the list
    IShape textBoxShape = slide.AddTextBox(65, 140, 410, 270);
    // Add a new paragraph with a text
    IParagraph paragraph = textBoxShape.TextBody.AddParagraph("Hello World");
    // Finds the text from the Presentation document
    ITextSelection textSelection = presentation.Find("World", false, false);
    // Gets the selected text from the text selection
    string text = textSelection.SelectedText;
    //Save the presentation
    presentation.Save("Output.pptx");
    //Close the presentation
    presentation.Close();
     'Creates a presentation.
     Dim presentation As IPresentation = Presentation.Create()
     'Add the slide into the presentation
     Dim slide As ISlide = presentation.Slides.Add(SlideLayoutType.Blank)
     'Add a text box to hold the list 
     Dim textBoxShape As IShape = slide.AddTextBox(65, 140, 410, 270)
     'Add a new paragraph with a text
     Dim paragraph As IParagraph = textBoxShape.TextBody.AddParagraph("Hello World")
     'Finds the text from the Presentation document
     Dim textSelection As ITextSelection = presentation.Find("World", False, False)
     'Gets the selected text from the text selection
     Dim text As String = textSelection.SelectedText
     presentation.Save("Output.pptx")
     presentation.Close()

    Methods

    GetAsOneTextPart()

    Gets as one text part.

    Declaration
    ITextPart GetAsOneTextPart()
    Returns
    Type Description
    ITextPart

    TextPart

    Examples
    //Create a new presentation instance.
    IPresentation presentation = Presentation.Create();
    //Add the slide into the presentation
    ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
    // Add a text box to hold the list
    IShape textBoxShape = slide.AddTextBox(65, 140, 410, 270);
    // Add a new paragraph with a text
    IParagraph paragraph = textBoxShape.TextBody.AddParagraph("Hello World");
    // Finds the text from the mentioned slide
    ITextSelection[] textSelections = slide.FindAll("World", false, false);
    foreach (ITextSelection textSelection in textSelections)
    {
        //Gets the found text as single text part
        ITextPart textPart = textSelection.GetAsOneTextPart();
        //Replace the text
        textPart.Text = "Replaced text";
    }
    //Save the presentation
    presentation.Save("Output.pptx");
    //Close the presentation
    presentation.Close();
     'Creates a presentation.
     Dim presentation As IPresentation = Presentation.Create()
     'Add the slide into the presentation
     Dim slide As ISlide = presentation.Slides.Add(SlideLayoutType.Blank)
     'Add a text box to hold the list 
     Dim textBoxShape As IShape = slide.AddTextBox(65, 140, 410, 270)
     'Add a new paragraph with a text
     Dim paragraph As IParagraph = textBoxShape.TextBody.AddParagraph("Hello World")
     'Finds the text from the mentioned slide
     Dim textSelections As ITextSelection() = slide.FindAll("World", False, False)
     'Gets the found text as single text part and replace it
     For Each textSelection As ITextSelection In textSelections
         Dim textPart As ITextPart = textSelection.GetAsOneTextPart()
         textPart.Text = "Replaced text"
     Next
     presentation.Save("Output.pptx")
     presentation.Close()

    GetTextParts()

    Gets the selected text parts.

    Declaration
    ITextPart[] GetTextParts()
    Returns
    Type Description
    ITextPart[]

    Array of TextParts

    Examples
    //Create a new presentation instance.
    IPresentation presentation = Presentation.Create();
    //Add the slide into the presentation
    ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
    // Add a text box to hold the list
    IShape textBoxShape = slide.AddTextBox(65, 140, 410, 270);
    // Add a new paragraph with a text
    IParagraph paragraph = textBoxShape.TextBody.AddParagraph("Hello World");
    ITextSelection textSelection = presentation.Find("World", false, false);
    // Gets the found text containing text parts
    foreach (ITextPart textPart in textSelection.GetTextParts())
    {
       //Sets Bold property
       textPart.Font.Bold = true;
    }
    //Save the presentation
    presentation.Save("Output.pptx");
    //Close the presentation
    presentation.Close();
     'Creates a presentation.
     Dim presentation As IPresentation = Presentation.Create()
     'Add the slide into the presentation
     Dim slide As ISlide = presentation.Slides.Add(SlideLayoutType.Blank)
     'Add a text box to hold the list 
     Dim textBoxShape As IShape = slide.AddTextBox(65, 140, 410, 270)
     'Add a new paragraph with a text
     Dim paragraph As IParagraph = textBoxShape.TextBody.AddParagraph("Hello World")
     'Finds the text from the Presentation document
     Dim textSelection As ITextSelection = presentation.Find("World", False, False)
     'Gets the text parts from the selection
     For Each textPart As ITextPart In textSelection.GetTextParts()
         textPart.Font.Bold = True
     Next
     presentation.Save("Output.pptx")
     presentation.Close()

    Extension Methods

    DateTimeExtension.ToDateTime(Object)
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved