C#从日历中获取所选日期并将其显示在消息框中

时间:2013-06-17 13:57:06

标签: c# calendar

C#从日历中获取所选日期并将其显示在消息框中,以后数据将用于将自动生成的电子邮件中。

我在视觉工作室2012中使用标准的月历,我希望用户选择的日期与消息框中的其余数据一起显示,但是我发现很难通过只是选定的日期,而不是整个日期范围。

我对C#非常了解,目前我正在大学学习,但这在我的课程中没有涉及:S。

这是我到目前为止所做的:

    //Calendar
    private void completionCalendar_DateChanged(object sender, DateRangeEventArgs e)
    {

    }



//Button
        private void submitButton_Click(object sender, EventArgs e)
        {
//pretty sure the maxselectioncount is in the wrong place 

        completionCalendar.MaxSelectionCount = 1;

   MessageBox.Show("Date they start: " + completionCalendar);

        }

我只是在寻找一个漂亮而简单/ dd / mm / yyyy甚至dd-mm-yyyy等等任何帮助吗?

1 个答案:

答案 0 :(得分:1)

试试上面的

   private void submitButton_Click(object sender, EventArgs e)
    {

        MessageBox.Show("Date they start: " + completionCalendar.SelectionEnd.ToString("dd-mm-yyyy"));

    }