C#使用DateTimepiker获取并设置日期示例
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
DateTime result = DateTime.Today.Subtract(TimeSpan.FromDays(0));
dateTimePicker1.Value = result;
}
private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
DateTime result = dateTimePicker1.Value;
this.Text = result.ToString();
}
}
}
在C#中,我们可以使用DateTimepiker设置日期和时间。
日期:2020-04-11 23:03:50 来源:oir作者:oir
