CoreSuite.DateTimeBox 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package CoreSuite.DateTimeBox --version 1.0.0
                    
NuGet\Install-Package CoreSuite.DateTimeBox -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CoreSuite.DateTimeBox" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CoreSuite.DateTimeBox" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="CoreSuite.DateTimeBox" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CoreSuite.DateTimeBox --version 1.0.0
                    
#r "nuget: CoreSuite.DateTimeBox, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CoreSuite.DateTimeBox@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CoreSuite.DateTimeBox&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=CoreSuite.DateTimeBox&version=1.0.0
                    
Install as a Cake Tool

CoreSuite DateTimeBox

CoreSuite.DateTimeBox is a culture-aware Windows Forms control for entering and selecting a complete date and time in a single field. It combines masked keyboard input with a dropdown editor containing a calendar, a time selector, and explicit confirmation and cancellation actions.

Features

  • Culture-aware date and time parsing and formatting
  • Short date pattern obtained from the configured culture
  • Short or long time pattern depending on ShowSeconds
  • Masked keyboard input
  • Combined calendar and time dropdown editor
  • Explicit OK and Cancel actions
  • Optional custom dropdown button image
  • Built-in calendar and clock glyph when no image is assigned
  • Data binding through the DateTime property
  • Windows Forms designer and smart tag support
  • Empty-value support through DateTime.MinValue and ClearDateTime()

Requirements

  • .NET 8
  • Windows Forms
  • Windows operating system

Installation

Install the package from NuGet:

dotnet add package CoreSuite.DateTimeBox

Or use the NuGet Package Manager:

Install-Package CoreSuite.DateTimeBox

The package automatically includes its required CoreSuite dependencies.

Basic usage

Dim AppointmentBox As New DateTimeBox With {
    .DateTimeCulture = Globalization.CultureInfo.GetCultureInfo("pt-BR"),
    .ShowSeconds = False,
    .DateTime = New DateTime(2026, 8, 2, 14, 30, 0),
    .Width = 180
}

AddHandler AppointmentBox.DateTimeValueChanged,
    Sub(sender As Object, e As EventArgs)
        If AppointmentBox.HasDateTime Then
            Console.WriteLine(AppointmentBox.DateTime)
        End If
    End Sub

Main properties

Property Type Default Description
DateTime DateTime DateTime.MinValue Gets or sets the represented date and time. Assigning DateTime.MinValue clears the control.
HasDateTime Boolean False Indicates whether the control currently contains a valid date and time.
DateTimeCulture CultureInfo CultureInfo.CurrentCulture Defines the culture used for parsing, formatting, and the dropdown editor.
ShowSeconds Boolean False Determines whether seconds are displayed and accepted.
ButtonImage Image Nothing Defines a custom image for the dropdown button.

Event

DateTimeValueChanged

Occurs whenever the represented value changes, including when a valid value is entered, selected from the dropdown, or cleared.

Private Sub AppointmentBox_DateTimeValueChanged(sender As Object, e As EventArgs) Handles AppointmentBox.DateTimeValueChanged
    If AppointmentBox.HasDateTime Then
        Text = AppointmentBox.DateTime.ToString("F", AppointmentBox.DateTimeCulture)
    Else
        Text = "No appointment selected"
    End If
End Sub

Clearing the value

Use either ClearDateTime() or assign DateTime.MinValue:

AppointmentBox.ClearDateTime()

' Equivalent behavior:
AppointmentBox.DateTime = DateTime.MinValue

Culture examples

AppointmentBox.DateTimeCulture = Globalization.CultureInfo.GetCultureInfo("pt-BR")
' Example: 02/08/2026 14:30

AppointmentBox.DateTimeCulture = Globalization.CultureInfo.GetCultureInfo("en-US")
' Example: 08/02/2026 02:30 PM

Single-character date and time components are normalized internally so they can be represented consistently by the masked input control.

Showing seconds

AppointmentBox.ShowSeconds = True
AppointmentBox.DateTime = New DateTime(2026, 8, 2, 14, 30, 45)

When ShowSeconds is False, seconds remain part of a programmatically assigned or dropdown-selected value but are not shown by the control.

Data binding

DateTime is the control's default binding property:

AppointmentBox.DataBindings.Add(
    NameOf(AppointmentBox.DateTime),
    ViewModel,
    NameOf(ViewModel.AppointmentDateTime),
    formattingEnabled:=True,
    updateMode:=DataSourceUpdateMode.OnPropertyChanged)

Because an empty control exposes DateTime.MinValue, convert that sentinel value when binding to a nullable model property.

The dropdown starts with the current control value. If the control is empty, it starts with the current local date and time.

  • OK combines the selected calendar date with the selected time and updates the control.
  • Cancel closes the dropdown without changing the control.
  • Closing the dropdown by clicking elsewhere also leaves the existing value unchanged.
  • Pressing Enter while the field is focused opens the dropdown editor.

License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible.  net9.0-windows was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.2 86 8/7/2026
1.0.1 93 8/3/2026
1.0.0 99 8/2/2026

Initial release of the DateTimeBox control.