Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在c#.net中更改日历的格式_C#_.net_Winforms - Fatal编程技术网

如何在c#.net中更改日历的格式

如何在c#.net中更改日历的格式,c#,.net,winforms,C#,.net,Winforms,在标签中,它以mm dd yyyy格式显示。 但我希望格式为dd-mm-yyyy。试试这个: protected void Page_Load(object sender, EventArgs e) { Label1.Text = "Select Date:-"; Calendar1.SelectedDate = DateTime.Now; } protected void Calendar1_SelectionChanged(obje

在标签中,它以mm dd yyyy格式显示。
但我希望格式为dd-mm-yyyy。

试试这个:

 protected void Page_Load(object sender, EventArgs e)
    {
        Label1.Text = "Select Date:-";
        Calendar1.SelectedDate = DateTime.Now;
    }

    protected void Calendar1_SelectionChanged(object sender, EventArgs e)
    {

        Label1.Text = Label1.Text + Calendar1.SelectedDate.ToShortDateString();

    }

假设OP不想更改日历本身中显示的日期格式,那么就这样做吧。但是我认为在你的格式字符串中“mm”应该是“mm”(大写)。是的,我刚偏离了他的格式。但我同意。
Label1.Text = Label1.Text + Calendar1.SelectedDate.ToString("dd-MM-yyyy");