# DateFormField Class

> An object of the DateFormField class represents a date field on a form. It can be initially empty and it can have a horizontal extension, when it is empty. When a date field is clicked or entered through the keyboard's arrow keys a date control is shown where the user can select a date. When the date field is clicked again or the Escape key is pressed the date control is removed and the user can insert or change the date with the keyboard. The date is formatted depending on the culture used for the text of the date field. When a date field is inserted at a position without a set culture, a TextControl uses the system language to select a culture. Supported formats for a certain language can be obtained through the DateFormField.SupportedDateFormats property and can be set with the DateFormField.DateFormat property. When the DateFormat property is an empty string, which is the default, the culture's default format is used. A user can also insert or change a date with the keyboard, then the TextControl tries to parse the inserted date depending on the specified format and culture and automatically formats the date. When parsing is not possible the previous date is restored.

- **Product:** TX Text Control .NET for Windows Forms
- **Section:** Reference
- **Kind:** Class
- **Introduced:** 28.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.TextField` › `TXTextControl.FormField`
- **Path:** TX Text Control .NET for Windows Forms > Reference > TXTextControl > DateFormField Class
- **1319 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/dateformfield/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/dateformfield/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/dateformfield/llms-full.txt

---

### Description

An object of the DateFormField class represents a date field on a form. It can be initially empty and it can have a horizontal extension, when it is empty. When a date field is clicked or entered through the keyboard's arrow keys a date control is shown where the user can select a date. When the date field is clicked again or the Escape key is pressed the date control is removed and the user can insert or change the date with the keyboard. The date is formatted depending on the culture used for the text of the date field. When a date field is inserted at a position without a set culture, a TextControl uses the system language to select a culture. Supported formats for a certain language can be obtained through the [DateFormField.SupportedDateFormats](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/dateformfield/supporteddateformats-property/llms-full.txt) property and can be set with the [DateFormField.DateFormat](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/dateformfield/dateformat-property/llms-full.txt) property. When the DateFormat property is an empty string, which is the default, the culture's default format is used. A user can also insert or change a date with the keyboard, then the TextControl tries to parse the inserted date depending on the specified format and culture and automatically formats the date. When parsing is not possible the previous date is restored.

### Syntax

```csharp
public class DateFormField : FormField
```

```vbnet
Public Class DateFormField
    Inherits FormField
```

### Examples

The following example adds a prefilled delivery-date field to a form.

```csharp
DateFormField dateFormField = new(DateTime.Today.AddDays(14), 0) { Name = "DeliveryDate" };
textControl.FormFields.Add(dateFormField);
```

```vbnet
Dim dateFormField As New DateFormField(Date.Today.AddDays(14), 0) With { .Name = "DeliveryDate" }
textControl.FormFields.Add(dateFormField)
```

---

## In This Section

- [DateFormField Constructor](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/dateformfield/constructor/llms-full.txt): Initializes a new instance of the DateFormField class.
- [DateFormField.Date Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/dateformfield/date-property/llms-full.txt): Gets or sets the DateFormField's date.
- [DateFormField.DateFormat Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/dateformfield/dateformat-property/llms-full.txt): Gets or sets the date's format. For a certain DateFormField the format string should be one of the strings returned through the SupportedDateFormats property. A TextControl uses Day, Month, Year, and Era Format Picture strings to format a date. When this property is an empty string, which is the default value, a default format is used depending on the culture set for the date field's text.
- [DateFormField.EmptyWidth Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/dateformfield/emptywidth-property/llms-full.txt): Gets or sets the horizontal extension, in twips, of the DateFormField, when a date is not set.
- [DateFormField.IsDateControlVisible Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/dateformfield/isdatecontrolvisible-property/llms-full.txt): Gets or sets a value indicating wheather a date control is shown below the DateFormField so that the user can select a date.
- [DateFormField.SupportedDateFormats Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/dateformfield/supporteddateformats-property/llms-full.txt): Gets an array of format picture strings which can be used to format the date. The returned format strings depend on the culture set for the date field's text. A TextControl uses Day, Month, Year, and Era Format Picture strings to format a date.

---

## Nearby

- **Previous:** [CursorKind Enumeration](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/cursorkind/enumeration/llms-full.txt)
- **Next:** [DateFormField Constructor](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/dateformfield/constructor/llms-full.txt)
