WinForms DateTimePicker对话框?

Jam*_*mes 4 c# calendar popup datetimepicker winforms

我需要有一个弹出对话框,如颜色对话框或保存对话框,但需要从日历中选择日期.DateTimePicker是我需要的,但我不知道如何像C#中的弹出对话框那样启动它.

Lee*_*Lee 8

您需要将DateTimePicker添加到窗体并将窗体显示为对话框:

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

var result = f.ShowDialog();
if(result == DialogResult.OK)
{
    //get selected date
}
Run Code Online (Sandbox Code Playgroud)