# SelectionFormField Constructor

> Initializes a new instance of the SelectionFormField class.

- **Product:** TX Text Control .NET for WPF
- **Section:** Reference
- **Kind:** Constructor
- **Introduced:** 28.0
- **Namespace:** `TXTextControl`
- **Package:** `TXTextControl.TextControl.WPF.SDK` (assembly `TXTextControl.dll`, from the private NuGet feed or Text Control Offline Packages)
- **.NET Framework:** reference `TXTextControl.dll` from the setup
- **Path:** TX Text Control .NET for WPF > Reference > TXTextControl > SelectionFormField Constructor
- **738 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/selectionformfield/constructor/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/selectionformfield/constructor/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/selectionformfield/constructor/llms-full.txt

---

### Description

Initializes a new instance of the SelectionFormField class.

### Syntax

#### SelectionFormField(int)

Initializes a new instance of an empty SelectionFormField. It has no items and no text.

```csharp
public SelectionFormField(int emptyWidth);
```

```vbnet
Public Sub New(emptyWidth As Integer)
```

| Parameter | Description |
|---|---|
| emptyWidth | Specifies the horizontal extension, in twips, of the SelectionFormField, when there is no selected item. When this parameter is set to 0, a default value is used. |

#### SelectionFormField(string\[\], int)

Initializes a new instance of a SelectionFormField with the specified items and the index of the selected item.

```csharp
public SelectionFormField(string[] items, int selectedIndex);
```

```vbnet
Public Sub New(items As String(), selectedIndex As Integer)
```

| Parameter | Description |
|---|---|
| items | Specifies a list of items for the SelectionFormField. |
| selectedIndex | Specifies the zero-based index of the selected item. When this parameter is -1, no item is selected. |

### Examples

The following example adds a country selector to a fillable form.

```csharp
SelectionFormField selectionFormField = new(new[] { "Germany", "United Kingdom", "United States" }, 0) { Name = "Country" };
textControl.FormFields.Add(selectionFormField);
```

```vbnet
Dim selectionFormField As New SelectionFormField(New String() { "Germany", "United Kingdom", "United States" }, 0) With { .Name = "Country" }
textControl.FormFields.Add(selectionFormField)
```

---

## Nearby

- **Previous:** [SelectionFormField Class](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/selectionformfield/llms-full.txt)
- **Next:** [SelectionFormField.EmptyWidth Property](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/selectionformfield/emptywidth-property/llms-full.txt)
