Interface ITextParts
Represents a collection of ITextPart instance in a paragraph.
Namespace: Syncfusion.Presentation
Assembly: Syncfusion.Presentation.Portable.dll
Syntax
public interface ITextParts : IEnumerable<ITextPart>, IEnumerable
Properties
Count
Gets the number of elements in the text part collection. Read-only.
Declaration
int Count { get; }
Property Value
Type |
---|
System.Int32 |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Add a text box to the slide
IShape shape = slide.Shapes.AddTextBox(100, 150, 300, 200);
//Add paragraph to the shape's text body
IParagraph paragraph = shape.TextBody.Paragraphs.Add();
//Retrieve the text parts of a paragraph
ITextParts textParts = paragraph.TextParts;
//Add a text part to the collection
ITextPart textPart = textParts.Add();
//Set text to text part
textPart.Text = "Reynold Xin, PhD student at UC Berkeley AMPLab";
//Add text part to paragraph
shape.TextBody.Paragraphs[0].AddTextPart("First Paragraph, second TextPart");
//Get the count of the text parts, read only
int count = textParts.Count;
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Add a text box to the slide
Dim shape As IShape = slide.Shapes.AddTextBox(100, 150, 300, 200)
'Add paragraph to the shape's text body
Dim paragraph As IParagraph = shape.TextBody.Paragraphs.Add()
'Retrieve the text parts of a paragraph
Dim text parts As ITextParts = paragraph.TextParts
'Add a text part to the collection
Dim text part As ITextPart = text parts.Add()
'Set text to text part
text part.Text = "Reynold Xin, PhD student at UC Berkeley AMPLab"
'Add text part to paragraph
shape.TextBody.Paragraphs(0).AddTextPart("First Paragraph, second TextPart")
'Get the count of the text parts, read only
Dim count As Integer = text parts.Count
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
Item[Int32]
Gets a ITextPart instance at the specified index of the collection. Read-only.
Declaration
ITextPart this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Determines the index of the text part. |
Property Value
Type | Description |
---|---|
ITextPart | Returns an ITextPart instance. |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Add a text box to the slide
IShape shape = slide.Shapes.AddTextBox(100, 150, 300, 200);
//Add paragraph to the shape's text body
IParagraph paragraph = shape.TextBody.Paragraphs.Add();
//Retrieve the text parts of a paragraph
ITextParts textParts = paragraph.TextParts;
//Add a text part to the collection
ITextPart textPart = textParts.Add();
//Set text to text part
textPart.Text = "Reynold Xin, PhD student at UC Berkeley AMPLab";
//Add text part to paragraph
shape.TextBody.Paragraphs[0].AddTextPart();
//Retrieve the text part using index position
ITextPart _textPart = textParts[1];
//Set the font name for text part
_textPart.Font.FontName = "Calibri";
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Add a text box to the slide
Dim shape As IShape = slide.Shapes.AddTextBox(100, 150, 300, 200)
'Add paragraph to the shape's text body
Dim paragraph As IParagraph = shape.TextBody.Paragraphs.Add()
'Retrieve the text parts of a paragraph
Dim text parts As ITextParts = paragraph.TextParts
'Add a text part to the collection
Dim text part As ITextPart = text parts.Add()
'Set text to text part
text part.Text = "Reynold Xin, PhD student at UC Berkeley AMPLab"
'Add text part to paragraph
shape.TextBody.Paragraphs(0).AddTextPart()
'Retrieve the text part using index position
Dim _text part As ITextPart = text parts(1)
'Set the font name for text part
_text part.Font.FontName = "Calibri"
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
Methods
Add()
Adds a new ITextPart instance to the text part collection.
Declaration
ITextPart Add()
Returns
Type | Description |
---|---|
ITextPart | Returns the newly created ITextPart instance. |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Add a text box to the slide
IShape shape = slide.Shapes.AddTextBox(100, 150, 300, 200);
//Add paragraph to the shape's text body
IParagraph paragraph = shape.TextBody.Paragraphs.Add();
//Retrieve the text parts of a paragraph
ITextParts textParts = paragraph.TextParts;
//Add a text part to the collection
ITextPart textPart = textParts.Add();
//Set text to text part
textPart.Text = "Reynold Xin, PhD student at UC Berkeley AMPLab";
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Add a text box to the slide
Dim shape As IShape = slide.Shapes.AddTextBox(100, 150, 300, 200)
'Add paragraph to the shape's text body
Dim paragraph As IParagraph = shape.TextBody.Paragraphs.Add()
'Retrieve the text parts of a paragraph
Dim text parts As ITextParts = paragraph.TextParts
'Add a text part to the collection
Dim text part As ITextPart = text parts.Add()
'Set text to text part
text part.Text = "Reynold Xin, PhD student at UC Berkeley AMPLab"
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
Add(String)
Adds a new ITextPart instance at the end of the text part collection with the specified text.
Declaration
ITextPart Add(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | Represents the text content to initialize the text part. |
Returns
Type | Description |
---|---|
ITextPart | Returns the newly added ITextPart instance. |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Add a text box to the slide
IShape shape = slide.Shapes.AddTextBox(100, 150, 300, 200);
//Add paragraph to the shape's text body
IParagraph paragraph = shape.TextBody.Paragraphs.Add();
//Retrieve the text parts of a paragraph
ITextParts textParts = paragraph.TextParts;
//Add a text part to the collection
ITextPart textPart = textParts.Add("Reynold Xin, PhD student at UC Berkeley AMPLab");
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Add a text box to the slide
Dim shape As IShape = slide.Shapes.AddTextBox(100, 150, 300, 200)
'Add paragraph to the shape's text body
Dim paragraph As IParagraph = shape.TextBody.Paragraphs.Add()
'Retrieve the text parts of a paragraph
Dim text parts As ITextParts = paragraph.TextParts
'Add a text part to the collection
Dim text part As ITextPart = text parts.Add("Reynold Xin, PhD student at UC Berkeley AMPLab")
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
Clear()
Removes all the ITextPart instance from text part collection.
Declaration
void Clear()
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Add a text box to the slide
IShape shape = slide.Shapes.AddTextBox(100, 150, 300, 200);
//Add paragraph to the shape's text body
IParagraph paragraph = shape.TextBody.Paragraphs.Add();
//Retrieve the text parts of a paragraph
ITextParts textParts = paragraph.TextParts;
//Add a text part to the collection
ITextPart textPart = textParts.Add("Reynold Xin, PhD student at UC Berkeley AMPLab");
//Clear the text parts
textParts.Clear();
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Add a text box to the slide
Dim shape As IShape = slide.Shapes.AddTextBox(100, 150, 300, 200)
'Add paragraph to the shape's text body
Dim paragraph As IParagraph = shape.TextBody.Paragraphs.Add()
'Retrieve the text parts of a paragraph
Dim text parts As ITextParts = paragraph.TextParts
'Add a text part to the collection
Dim text part As ITextPart = text parts.Add("Reynold Xin, PhD student at UC Berkeley AMPLab")
'Clear the text parts
text parts.Clear()
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
Contains(String)
Returns a boolean value indicates whether the specified text content is in the text part collection or not.
Declaration
bool Contains(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to locate in the text part collection. |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if text founds in the collection otherwise false |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Add a text box to the slide
IShape shape = slide.Shapes.AddTextBox(100, 150, 300, 200);
//Add paragraph to the shape's text body
IParagraph paragraph = shape.TextBody.Paragraphs.Add();
//Retrieve the text parts of a paragraph
ITextParts textParts = paragraph.TextParts;
//Add text part to collection
textParts.Add("Reynold Xin, PhD student at UC Berkeley AMPLab");
//Add a text part to the collection
ITextPart textPart = textParts.Add();
//Set text to text part
textPart.Text = "My Textpart";
//Check if text exist in the text part collection
if (textParts.Contains("My Textpart"))
textParts.RemoveAt(1);
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Add a text box to the slide
Dim shape As IShape = slide.Shapes.AddTextBox(100, 150, 300, 200)
'Add paragraph to the shape's text body
Dim paragraph As IParagraph = shape.TextBody.Paragraphs.Add()
'Retrieve the text parts of a paragraph
Dim text parts As ITextParts = paragraph.TextParts
'Add text part to collection
text parts.Add("Reynold Xin, PhD student at UC Berkeley AMPLab")
'Add a text part to the collection
Dim text part As ITextPart = text parts.Add()
'Set text to text part
text part.Text = "My Textpart"
'Check if text exist in the text part collection
If text parts.Contains("My Textpart") Then
text parts.RemoveAt(1)
End If
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
IndexOf(ITextPart)
Returns the zero-based index of the first occurrence of the ITextPart instance within the collection.
Declaration
int IndexOf(ITextPart item)
Parameters
Type | Name | Description |
---|---|---|
ITextPart | item | The ITextPart instance to locate in the collection. |
Returns
Type | Description |
---|---|
System.Int32 | Returns the zero-based index of the first occurrence of ITextPart instance within the collection, if found; otherwise, –1. |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Add a text box to the slide
IShape shape = slide.Shapes.AddTextBox(100, 150, 300, 200);
//Add paragraph to the shape's text body
IParagraph paragraph = shape.TextBody.Paragraphs.Add();
//Retrieve the text parts of a paragraph
ITextParts textParts = paragraph.TextParts;
//Add text part to collection
textParts.Add("Reynold Xin, PhD student at UC Berkeley AMPLab");
//Add a text part to the collection
ITextPart textPart = textParts.Add();
//Set text to text part
textPart.Text = "My Textpart";
//Get the index position of a text part
int index = textParts.IndexOf(textPart);
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Add a text box to the slide
Dim shape As IShape = slide.Shapes.AddTextBox(100, 150, 300, 200)
'Add paragraph to the shape's text body
Dim paragraph As IParagraph = shape.TextBody.Paragraphs.Add()
'Retrieve the text parts of a paragraph
Dim text parts As ITextParts = paragraph.TextParts
'Add text part to collection
text parts.Add("Reynold Xin, PhD student at UC Berkeley AMPLab")
'Add a text part to the collection
Dim text part As ITextPart = text parts.Add()
'Set text to text part
text part.Text = "My Textpart"
'Get the index position of a text part
Dim index As Integer = text parts.IndexOf(text part)
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
Remove(ITextPart)
Removes the first occurrence of a specified ITextPart instance from the text part collection.
Declaration
void Remove(ITextPart item)
Parameters
Type | Name | Description |
---|---|---|
ITextPart | item | Represents the ITextPart instance to remove. |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Add a text box to the slide
IShape shape = slide.Shapes.AddTextBox(100, 150, 300, 200);
//Add paragraph to the shape's text body
IParagraph paragraph = shape.TextBody.Paragraphs.Add();
//Retrieve the text parts of a paragraph
ITextParts textParts = paragraph.TextParts;
//Add text part to collection
textParts.Add("Reynold Xin, PhD student at UC Berkeley AMPLab");
//Add a text part to the collection
ITextPart textPart = textParts.Add();
//Set text to text part
textPart.Text = "My Textpart";
//Remove a particular text part from collection
textParts.Remove(textPart);
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Add a text box to the slide
Dim shape As IShape = slide.Shapes.AddTextBox(100, 150, 300, 200)
'Add paragraph to the shape's text body
Dim paragraph As IParagraph = shape.TextBody.Paragraphs.Add()
'Retrieve the text parts of a paragraph
Dim text parts As ITextParts = paragraph.TextParts
'Add text part to collection
text parts.Add("Reynold Xin, PhD student at UC Berkeley AMPLab")
'Add a text part to the collection
Dim text part As ITextPart = text parts.Add()
'Set text to text part
text part.Text = "My Textpart"
'Remove a particular text part from collection
text parts.Remove(text part)
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
RemoveAt(Int32)
Removes the ITextPart instance at the specified index of the text part collection.
Declaration
void RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The zero-based index of the text part to be removed. |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Add a text box to the slide
IShape shape = slide.Shapes.AddTextBox(100, 150, 300, 200);
//Add paragraph to the shape's text body
IParagraph paragraph = shape.TextBody.Paragraphs.Add();
//Retrieve the text parts of a paragraph
ITextParts textParts = paragraph.TextParts;
//Add text part to collection
textParts.Add("Reynold Xin, PhD student at UC Berkeley AMPLab");
//Add a text part to the collection
ITextPart textPart = textParts.Add();
//Set text to text part
textPart.Text = "My Textpart";
//Remove text part at specific index
textParts.RemoveAt(1);
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Add a text box to the slide
Dim shape As IShape = slide.Shapes.AddTextBox(100, 150, 300, 200)
'Add paragraph to the shape's text body
Dim paragraph As IParagraph = shape.TextBody.Paragraphs.Add()
'Retrieve the text parts of a paragraph
Dim text parts As ITextParts = paragraph.TextParts
'Add text part to collection
text parts.Add("Reynold Xin, PhD student at UC Berkeley AMPLab")
'Add a text part to the collection
Dim text part As ITextPart = text parts.Add()
'Set text to text part
text part.Text = "My Textpart"
'Remove text part at specific index
text parts.RemoveAt(1)
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()