如何获得只能从Windows窗体DateTimePicker控件的日期值? [英] How to get only the date value from a Windows Forms DateTimePicker control?

查看:738
本文介绍了如何获得只能从Windows窗体DateTimePicker控件的日期值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在建设有C#代码的应用程序。结果
我如何得到只有从的DateTimePicker 控制权的日期值?

I'm building an application with C# code.
How do I get only the date value from a DateTimePicker control?

推荐答案

我假设你的意思是在一个WinForms应用程序中的日期时间选择器。

I'm assuming you mean a datetime picker in a winforms application.

在你的代码,你可以做到以下几点:

in your code, you can do the following:

string theDate = dateTimePicker1.Value.ToShortDateString();



或者,如果你想指定日期的格式为:

or, if you'd like to specify the format of the date:

string theDate = dateTimePicker1.Value.ToString("yyyy-MM-dd");

这篇关于如何获得只能从Windows窗体DateTimePicker控件的日期值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆