Skip to content

Custom datetimepicker control for Windows Forms that allows databinding to a nullable DateTime field

License

Notifications You must be signed in to change notification settings

pymendoza/NullableBindingDateTimePicker

Repository files navigation

NullableBindingDateTimePicker

Custom datetimepicker control for Windows Forms that allows databinding to a nullable DateTime field. Null datetime value is represented by an unchecked checkbox on the datetimepicker.

How to use:

  1. From Visual Studio Toolbox, drag and drop custom control to your form:

  1. Set the databindings to the Value property

public partial class Form1 : Form
{
    public Person Person = new Person();

    public Form1()
    {
        InitializeComponent();

        nullableBindingDateTimePicker1.DataBindings
            .Add("Value", Person, "Birthdate", true, DataSourceUpdateMode.OnPropertyChanged);
        
        // Show underlying bound field value
        label2.DataBindings.Add("Text", Person, "Birthdate");
    }
}

public class Person
{
    public DateTime? BirthDate { get; set; }
}

About

Custom datetimepicker control for Windows Forms that allows databinding to a nullable DateTime field

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages