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.

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的更多相关文章

  1. 基于bootstrap的datetimepicker插件

    1.当时使用的资源地址:http://www.bootcss.com/p/bootstrap-datetimepicker/ 2.如何让时间只显示到日期,不显示具体时刻 控制显示精度的是datetim ...

  2. Ext.util.Format.date 时间格式的设置与转换

    Ext.util.Format.date 如下这段简单的代码:  var d = new Date(value.time); var s = Ext.util.Format.date(d, 'Y-m- ...

  3. bootstrap--双日历插件

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  4. 自动开机和自动关机设定方法(包括linux和windows)

    (一) linux 机器 1.关机 : 编辑 /etc/crontab添加一条并且保证crontab服务的运行即可 f1 f2 f3 f4 f5 root sudo shutdown –h now 假 ...

  5. EXPDP IMPDP 知识总结

    Data Pump Export ATTACH Default: job currently in the user's schema, if there is only one Purpose(目的 ...

  6. (转载)iOS Framework: Introducing MKNetworkKit

    This article is available in Serbo-Croatian,  Japanese and German. (Translations in Serbo-Croatian b ...

  7. RH033读书笔记(14)-Lab 15 Switching Users and Setting a Umask

    Lab 15 Switching Users and Setting a Umask Goal: Become familiar with the use of several essential c ...

  8. JAVA提高五:注解Annotation

    今天我们学习JDK5.0中一个非常重要的特性,叫做注解.是现在非常流行的一种方式,可以说因为配置XML 比较麻烦或者比容易查找出错误,现在越来越多的框架开始支持注解方式,比如注明的Spring 框架, ...

  9. MySQL单机单实例安装脚本(转载)

    说明:使用mysql generic tar.gz包快速安装mysql 三个文件installation_of_single_mysql.sh.template_install-my.cnf.mysq ...

随机推荐

  1. POJ 1691 Painting A Board(DFS)

    链接 题意 : 看了好长时间终于看懂题目了,将一个大矩形划分成若干小矩形,告诉你每个小矩形的左上角那个点和右下角那个点的坐标,告诉你这个小矩形要涂的颜色,每个颜色对应一个刷子,问你最少要使用几次刷子. ...

  2. SDUT 1220 完美数

    完美数 Time Limit: 1000ms   Memory limit: 65536K 题目描述 任何一个自然数的约数中都有1和它本身,我们把小于它本身的因数叫做这个自然数的真约数. 如6的所有真 ...

  3. Linux Versus Windows, Ubuntu/Mint V XP/Vista/7

    原文:http://petermoulding.com/linux_versus_windows_ubuntu_mint_v_xp_vista_7 Linux Versus Windows, Ubun ...

  4. window下安装composer and yii2

    我的环境是集合包xampp 1,下载composer:下载地址https://getcomposer.org/download/, 点击蓝色字体“Composer-Setup.exe” 2,安装com ...

  5. Hibernate逍遥游记-第12章 映射值类型集合-002映射Bag(<idbag><collection-id>)

    1. 2. <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate ...

  6. cmd命令行指定系统延迟关机时间

    shutdown -s -t 3600 -c "想要显示的注释" -f 各参数的意思:-s 动作为关机 -t 3600 延迟3600秒关机 -c "想要显示的注释&quo ...

  7. C#中的Attribute和Java中的Annotation

    在之前的博客中介绍过C#的Attribute(特性),简单的说,特性主要就是利用反射技术,在运行期获取关注类的相关标注信息,然后利用这些标注信息对关注的类进行处理,最近因为工作的原因,需要看一下Jav ...

  8. php获取apk包信息的方法

    /*解析安卓apk包中的压缩XML文件,还原和读取XML内容 依赖功能:需要PHP的ZIP包函数支持.*/ include('./Apkparser.php'); $appObj = new Apkp ...

  9. Android 下log的使用总结

    Android 下log的使用总结 一:在源码开发模式下 1:包含头文件: #include <cutils/log.h> 2:定义宏LOG_TAG #define LOG_TAG &qu ...

  10. Codeforces Round #207 (Div. 2)C

    读错题意了..线段树延迟标记 白刷这么多线段树 #include <iostream> #include<cstdio> #include<cstring> #in ...