Question

I need to have a pop-up dialog like the Color Dialog or Save Dialog but for choosing a date from a calendar. The DateTimePicker is what I need, but I don't know how to launch this like a pop-up dialog in C#.

Was it helpful?

Solution

You need to add a DateTimePicker to a form and show the form as a dialog:

var picker = new DateTimePicker();
Form f = new Form();
f.Controls.Add(picker);

var result = f.ShowDialog();
if(result == DialogResult.OK)
{
    //get selected date
}

OTHER TIPS

The DateTimePicker is a Control, not a Form. You'll have to create your own Form and add the control to it; there is not a standard dialog for selecting dates.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top