码迷,mamicode.com
首页 > 其他好文 > 详细

How to enable DateTimePicker to use both date and time z

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

标签:c   style   class   http   a   ext   

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

标签:c   style   class   http   a   ext   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!