# Signature Fields

> Prepare documents for signing in Windows Forms: insert SignatureField frames with the ribbon or in C#, store SignerData, set signature images and handle events.

- **Product:** TX Text Control .NET for Windows Forms
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Text Control .NET for Windows Forms > Document Editor > Signature Fields
- **2907 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/signature-fields/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/signature-fields/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/signature-fields/llms-full.txt

---

Contracts, approvals and consent forms need a place where each signer signs. A signature field marks that place in the document: users draw it in the editor or your code inserts it, it stores who is expected to sign and why, and it receives the signature image. When the document is saved as PDF, each signature field can be digitally signed with a certificate.

The examples extend the application of [Create Your First Windows Forms Application](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/getting-started/document-editor/first-application/llms-full.txt), and *Form1.cs* needs `using TXTextControl;`. Signature fields were introduced in version 31.0. Applying certificates is covered by [Digital Signatures](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/digital-signatures/llms-full.txt); this page prepares the fields.

### What a Signature Field Is

A [SignatureField](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/signaturefield/llms-full.txt) is a frame that holds the image of a signature. The image can be added while the document is designed, or later, when the document is signed. A signature field is positioned like an image or a text frame: as a single character in the text, anchored to a paragraph, or at a fixed position on a page.

A signature field has:

- a **name**, which is required to associate the field with a certificate when the document is saved as PDF;
- **signer data**, the name, title, address and contact information of the expected signer and the reason for signing;
- an optional **image** of the signature.

Signature fields are saved in the TX Text Control format, PDF, DOCX and RTF. Other formats keep only the signature image. In a PDF, an unsigned signature field can also be signed later in a PDF reader such as Adobe Acrobat Reader.

### Insert Signature Fields With the Ribbon

On the **Insert** tab, the **Signature Field** button in the **Text** group inserts a signature field into the document:

![The Insert tab of a Windows Forms ribbon with the Signature Field button and its tooltip, and a document with two gray signature fields for Signer A and Signer B.](https://docs.textcontrol.com/assets/img/tx-text-control-dotnet-winforms/insert-tab-signature-field.bd0f146a.webp)

When a signature field is selected, the **Frame Formatting** tab appears. Its **Signer Info** group holds the signer, title, address, contact information and reason, and its **Properties** group the name and ID of the field:

![The Frame Formatting tab of a Windows Forms ribbon with the Signer Info group filled in for the selected signature field, and its name and ID in the Properties group.](https://docs.textcontrol.com/assets/img/tx-text-control-dotnet-winforms/frame-tab-signer-info.4e02cd65.webp)

The **Frame Formatting** tab is a [RibbonFrameLayoutTab](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms-ribbon/ribbonframelayouttab/llms-full.txt), and the **Insert** tab a [RibbonInsertTab](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms-ribbon/ribboninserttab/llms-full.txt). [Built-in Ribbon Tabs](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/ribbon-ui/ribbon/llms-full.txt) shows how to add them. [TextControl.SignatureFieldLayoutDialog](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/signaturefieldlayoutdialog-method/llms-full.txt) opens the dialog box with the layout, size and text distances of the selected signature field.

### Insert a Signature Field in Code

[TextControl.SignatureFields](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/signaturefields-property/llms-full.txt) returns the [SignatureFieldCollection](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/signaturefieldcollection/llms-full.txt) of the main text. The following handler inserts a named field with signer data at the input position:

```csharp
private void insertSignatureFieldButton_Click(object sender, EventArgs e)
{
    // 2.5 x 1 inch in twips (1 inch = 1440 twips); "txsign" is the name
    SignatureField signatureField = new SignatureField(new Size(3600, 1440), "txsign", 0)
    {
        SignerData = new SignerData(
            "Tim Typer", "Sales Manager", "", "tim@example.com", "Contract approval")
    };

    // Anchor the field to the paragraph at the input position (-1)
    bool added = textControl1.SignatureFields.Add(
        signatureField,
        TXTextControl.HorizontalAlignment.Left,
        -1,
        FrameInsertionMode.DisplaceText);

    if (!added)
    {
        MessageBox.Show("The signature field couldn't be added at this position.");
    }
}
```

The code works as follows:

- The [SignatureField constructor](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/signaturefield/constructor/llms-full.txt) takes the size in twips as a `System.Drawing.Size`, the name and an ID of your choice, where 0 means none.
- [SignerData](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/signerdata/constructor/llms-full.txt) takes the name, title, address and contact information of the expected signer and the reason for signing; parts you don't need can be empty or `null`. [SignatureField.SignerData](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/signaturefield/signerdata-property/llms-full.txt) stores it with the field.
- This overload of [SignatureFieldCollection.Add](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/signaturefieldcollection/add-method/llms-full.txt) anchors the field to the paragraph at a text position, where -1 stands for the input position, with a horizontal alignment and a [FrameInsertionMode](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/frameinsertionmode/enumeration/llms-full.txt). `DisplaceText` lets the text flow around the field. `HorizontalAlignment` is qualified with `TXTextControl.`, because Windows Forms has a type of the same name.

Other overloads of `Add` insert the field as a character (`Add(signatureField, -1)`), at a location relative to the paragraph, at a fixed position on a page, or let the user draw it:

```csharp
private void drawSignatureFieldButton_Click(object sender, EventArgs e)
{
    // The user draws the field with the mouse; ESC cancels
    SignatureField signatureField = new SignatureField(new Size(0, 0), "txsign_2", 0);
    textControl1.SignatureFields.Add(signatureField, FrameInsertionMode.DisplaceText);
}
```

With this overload, a cross cursor shows where the field can be inserted, and the user determines its size. Changing the document or pressing ESC cancels the insertion. [Images](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/images/llms-full.txt) and [Text Frames and Shapes](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/text-frames-shapes/llms-full.txt) explain these kinds of placement.

### Set an Image and Remove a Field

```csharp
private void setImageButton_Click(object sender, EventArgs e)
{
    SignatureField signatureField = textControl1.SignatureFields.GetItem("txsign");

    if (signatureField != null)
    {
        // Filter index 8 is SVG, 4 is PNG
        signatureField.Image = new SignatureImage("signature.svg", 8);
    }
}

private void removeSignatureFieldButton_Click(object sender, EventArgs e)
{
    // The signature field the user has selected, or null
    SignatureField signatureField = textControl1.SignatureFields.GetItem();

    if (signatureField != null)
    {
        textControl1.SignatureFields.Remove(signatureField);
    }
}
```

- [GetItem](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/signaturefieldcollection/getitem-method/llms-full.txt) returns the selected signature field, or the one with a name or an ID, and `null` if there is none.
- [SignatureField.Image](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/signaturefield/image-property/llms-full.txt) takes a [SignatureImage](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/signatureimage/constructor/llms-full.txt), loaded from a file with the index of its format, from a `System.Drawing.Image` or from a `MemoryStream`. Setting `Image` to `null` removes the image. [Add a Signature Image](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/digital-signatures/signature-fields/#add-a-signature-image) lists the format indexes and how the image is saved with the document.
- [Remove](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/signaturefieldcollection/remove-method/llms-full.txt) deletes the signature field.

### React to Signature Field Events

`TextControl` raises [SignatureFieldCreated](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/signaturefieldcreated-event/llms-full.txt), [SignatureFieldDeleted](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/signaturefielddeleted-event/llms-full.txt), [SignatureFieldSelected](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/signaturefieldselected-event/llms-full.txt), [SignatureFieldDeselected](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/signaturefielddeselected-event/llms-full.txt) and [SignatureFieldClicked](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/signaturefieldclicked-event/llms-full.txt). The handlers receive a [SignatureFieldEventArgs](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/signaturefieldeventargs/llms-full.txt) with the field. The following handler shows the expected signer when the user selects a field:

```csharp
public Form1()
{
    InitializeComponent();
    textControl1.SignatureFieldSelected += textControl1_SignatureFieldSelected;
}

private void textControl1_SignatureFieldSelected(object sender, SignatureFieldEventArgs e)
{
    SignerData signer = e.SignatureField.SignerData;
    Text = e.SignatureField.Name + (signer != null ? ", expected signer: " + signer.Name : "");
}
```

### Sign the Fields

Signature fields are signed when the document is saved as PDF: [SaveSettings.SignatureFields](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/savesettings/signaturefields-property/llms-full.txt) takes one [DigitalSignature](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/digitalsignature/llms-full.txt) per field, each with a certificate and the name of the field it signs. In a document with several signers, give each signer a field with its own name. [Digitally Sign a PDF](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/getting-started/pdf/sign/llms-full.txt) signs a field step by step, and [Signature Fields and Signature Appearance](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/digital-signatures/signature-fields/llms-full.txt) in Digital Signatures goes further.

The blog article [Sneak Peek 31.0: Signature Fields](https://www.textcontrol.com/blog/2022/05/27/sneak-peek-310-signature-fields/) introduces the feature with the ribbon and code, and [Preparing Documents for E-Signing for Multiple Signers in .NET C#](https://www.textcontrol.com/blog/2024/11/13/preparing-documents-for-e-signing-for-multiple-signers-in-net-c-sharp/) prepares fields for several signers.

### Next Steps

- [Digitally Sign a PDF](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/getting-started/pdf/sign/llms-full.txt): sign a signature field with a certificate.
- [Form Fields and Conditional Instructions](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/form-fields/llms-full.txt): fields that users fill out.
- [Signing PDF Documents](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/digital-signatures/signing/llms-full.txt): sign whole documents and fields.

---

## Nearby

- **Previous:** [Form Fields and Conditional Instructions](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/form-fields/llms-full.txt)
- **Next:** [Track Changes](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/track-changes/llms-full.txt)
