代码改变世界

使用DateTimePicker控件

2012-04-08 09:17  精诚所至 金石为开  阅读(477)  评论(0编辑  收藏  举报

本例创建一个DateTimePicker控件,利用其ValueChanged事件,改变RickTextBox的值,程序运行界面如下。

20120409091546 20120409091558

程序代码如下。

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace eg39_testApp
{
	public partial class MainForm : Form
	{
		public MainForm()
		{
			InitializeComponent();
		}
		
		void DateTimePicker1ValueChanged(object sender, EventArgs e)
		{
			richTextBox1.Text=dateTimePicker1.Value.Date.ToShortDateString()+"做的事情如下:\n";
			richTextBox1.Text+="------\n";
		}
	}
}