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:
- From Visual Studio Toolbox, drag and drop custom control to your form:
- 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; }
}