悟生慧

 

当前日期和选择日期之间的时差显示

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 GoldCubePos.App
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            ToolStripControlHost dateTimeCal;
            dateTimeCal = new ToolStripControlHost(new DateTimePicker());
            ((DateTimePicker)dateTimeCal.Control).ValueChanged += delegate { toolStripLabel1.Text = ((DateTimePicker)dateTimeCal.Control).Value.Subtract(DateTime.Now).ToString(); };

            dateTimeCal.Width = 200;
            toolStrip1.Width = 250;
            dateTimeCal.DisplayStyle = ToolStripItemDisplayStyle.Text;
            toolStrip1.Items.Add(dateTimeCal);
        }

}

}

posted on 2011-06-08 16:30  悟生慧  阅读(275)  评论(0编辑  收藏  举报

导航