# TextFrameCollection Class

> An instance of the TextFrameCollection class contains all text frames in a Text Control document or part of the document represented through objects of the type TextFrame. An instance of this class can be obtained with the TextControl.TextFrames or the HeaderFooter.TextFrames property. The TextFrameCollection class implements the IEnumerable and the ICollection interfaces.

- **Product:** TX Text Control .NET for Windows Forms
- **Section:** Reference
- **Kind:** Class
- **Introduced:** 12.0
- **Namespace:** `TXTextControl`
- **Package:** `TXTextControl.TextControl.WinForms.SDK` (assembly `TXTextControl.dll`, from the private NuGet feed or Text Control Offline Packages)
- **.NET Framework:** reference `TXTextControl.dll` from the setup
- **Inherits:** `TXTextControl.FrameBaseCollection`
- **Implements:** `System.Collections.ICollection`, `System.Collections.IEnumerable`
- **Path:** TX Text Control .NET for Windows Forms > Reference > TXTextControl > TextFrameCollection Class
- **1614 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textframecollection/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textframecollection/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textframecollection/llms-full.txt

---

### Description

An instance of the TextFrameCollection class contains all text frames in a Text Control document or part of the document represented through objects of the type [TextFrame](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textframe/llms-full.txt). An instance of this class can be obtained with the [TextControl.TextFrames](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/textframes-property/llms-full.txt) or the [HeaderFooter.TextFrames](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/headerfooter/textframes-property/llms-full.txt) property. The TextFrameCollection class implements the IEnumerable and the ICollection interfaces.

### Syntax

```csharp
public sealed class TextFrameCollection : FrameBaseCollection
```

```vbnet
Public NotInheritable Class TextFrameCollection
    Inherits FrameBaseCollection
```

### Examples

The following example checks all text frames in the collection and adds text field if the back color is blue:

```csharp
foreach (TXTextControl.TextFrame myFrame in textControl1.TextFrames)
{
    if (myFrame.BackColor == Color.Blue)
    {
        myFrame.TextFields.Add(new TXTextControl.TextField("Text field"));
    }
}
```

```vbnet
For Each MyFrame As TXTextControl.TextFrame In TextControl1.TextFrames
    If MyFrame.BackColor = Color.Blue Then
        MyFrame.TextFields.Add(New TXTextControl.TextField("Text field"))
    End If
Next
```

The following example works with text frames in the current document.

```csharp
TextFrameCollection textFrameCollection = textControl.TextFrames;
textFrameCollection.Add(new TextFrame(new System.Drawing.Size(3000, 1200)) { Name = "Callout", ID = 100 }, TextFrameInsertionMode.DisplaceText);
```

```vbnet
Dim textFrameCollection As TextFrameCollection = textControl.TextFrames
textFrameCollection.Add(New TextFrame(New System.Drawing.Size(3000, 1200)) With { .Name = "Callout", .ID = 100 }, TextFrameInsertionMode.DisplaceText)
```

---

## In This Section

- [TextFrameCollection.Add Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textframecollection/add-method/llms-full.txt): Inserts a new text frame in a Text Control document.
- [TextFrameCollection.CopyTo Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textframecollection/copyto-method/llms-full.txt): Copies the elements of the collection to an array, starting at a particular index.
- [TextFrameCollection.DeactivateItem Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textframecollection/deactivateitem-method/llms-full.txt): Deactivates the activated text frame and sets the input focus back to the text part that contains the text frame.
- [TextFrameCollection.GetActivatedItem Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textframecollection/getactivateditem-method/llms-full.txt): Returns the currently activated text frame. An activated text frame has the input focus and can be edited. The method returns null, if no text frame is activated.
- [TextFrameCollection.GetItem Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textframecollection/getitem-method/llms-full.txt): Gets a particular text frame from the collection.
- [TextFrameCollection.Remove Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textframecollection/remove-method/llms-full.txt): Removes a text frame from a Text Control document.

---

## Nearby

- **Previous:** [TextFrame.Transparency Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textframe/transparency-property/llms-full.txt)
- **Next:** [TextFrameCollection.Add Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textframecollection/add-method/llms-full.txt)
