首页 > 其他 > 详细

How to enable DateTimePicker to use both date and time z

时间:2014-05-29 17:46:51      阅读:391      评论:0      收藏:0      [点我收藏+]

Recently in one of my project I needed to have an option to display the DateTimePicker allowing user to pick both the date and the time. When I drag the control onto the form however I could only chooses the date or the time but not both. Well actually you can have both, all you have to do is use the CustomFormat property.

bubuko.com,布布扣

Here‘s how:

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 WindowsFormsApplication1

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

            this.dateTimePicker1.CustomFormat = "MM/dd/yyyy HH:mm";

            this.dateTimePicker1.Format = System.Windows.Forms.DateTimePickerFormat.Custom;

 

        }

    }

}

How to enable DateTimePicker to use both date and time z,布布扣,bubuko.com

How to enable DateTimePicker to use both date and time z

原文:http://www.cnblogs.com/zeroone/p/3758353.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!