Skip to content

Latest commit

 

History

History
35 lines (27 loc) · 1.08 KB

README.md

File metadata and controls

35 lines (27 loc) · 1.08 KB

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; }
}