DateTimePicker Format: Short, Time, default and Custom Format : DateTimePicker « GUI Windows Form « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Design Patterns
8.Development Class
9.Event
10.File Stream
11.Generics
12.GUI Windows Form
13.Language Basics
14.LINQ
15.Network
16.Office
17.Reflection
18.Regular Expressions
19.Security
20.Services Event
21.Thread
22.Web Services
23.Windows
24.Windows Presentation Foundation
25.XML
26.XML LINQ
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » GUI Windows Form » DateTimePickerScreenshots 
DateTimePicker Format: Short, Time, default and Custom Format
DateTimePicker Format: Short, Time, default and Custom Format


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

public class Form1 : Form
{
  private System.Windows.Forms.DateTimePicker dateTimePicker1;
  private System.Windows.Forms.Label label1;
  private System.Windows.Forms.Label label2;
  private System.Windows.Forms.Label label3;
  private System.Windows.Forms.Label label4;
  private System.Windows.Forms.DateTimePicker dateTimePicker2;
  private System.Windows.Forms.DateTimePicker dateTimePicker3;
  private System.Windows.Forms.DateTimePicker dateTimePicker4;

  public Form1() {
        InitializeComponent();
  }

  private void InitializeComponent()
  {
    this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
    this.label1 = new System.Windows.Forms.Label();
    this.label2 = new System.Windows.Forms.Label();
    this.label3 = new System.Windows.Forms.Label();
    this.label4 = new System.Windows.Forms.Label();
    this.dateTimePicker2 = new System.Windows.Forms.DateTimePicker();
    this.dateTimePicker3 = new System.Windows.Forms.DateTimePicker();
    this.dateTimePicker4 = new System.Windows.Forms.DateTimePicker();
    this.SuspendLayout();
    // 
    // dateTimePicker1
    // 
    this.dateTimePicker1.Location = new System.Drawing.Point(9215);
    this.dateTimePicker1.Name = "dateTimePicker1";
    this.dateTimePicker1.Size = new System.Drawing.Size(20021);
    this.dateTimePicker1.TabIndex = 0;
    // 
    // label1
    // 
    this.label1.AutoSize = true;
    this.label1.Location = new System.Drawing.Point(1219);
    this.label1.Name = "label1";
    this.label1.Size = new System.Drawing.Size(3013);
    this.label1.TabIndex = 2;
    this.label1.Text = "Long:";
    // 
    // label2
    // 
    this.label2.AutoSize = true;
    this.label2.Location = new System.Drawing.Point(1254);
    this.label2.Name = "label2";
    this.label2.Size = new System.Drawing.Size(3313);
    this.label2.TabIndex = 3;
    this.label2.Text = "Short:";
    // 
    // label3
    // 
    this.label3.AutoSize = true;
    this.label3.Location = new System.Drawing.Point(1292);
    this.label3.Name = "label3";
    this.label3.Size = new System.Drawing.Size(2913);
    this.label3.TabIndex = 4;
    this.label3.Text = "Time:";
    // 
    // label4
    // 
    this.label4.AutoSize = true;
    this.label4.Location = new System.Drawing.Point(12128);
    this.label4.Name = "label4";
    this.label4.Size = new System.Drawing.Size(6413);
    this.label4.TabIndex = 5;
    this.label4.Text = "Custom ISO:";
    // 
    // dateTimePicker2
    // 
    this.dateTimePicker2.Format = System.Windows.Forms.DateTimePickerFormat.Short;
    this.dateTimePicker2.Location = new System.Drawing.Point(9250);
    this.dateTimePicker2.Name = "dateTimePicker2";
    this.dateTimePicker2.Size = new System.Drawing.Size(20021);
    this.dateTimePicker2.TabIndex = 6;
    // 
    // dateTimePicker3
    // 
    this.dateTimePicker3.Format = System.Windows.Forms.DateTimePickerFormat.Time;
    this.dateTimePicker3.Location = new System.Drawing.Point(9288);
    this.dateTimePicker3.Name = "dateTimePicker3";
    this.dateTimePicker3.Size = new System.Drawing.Size(20021);
    this.dateTimePicker3.TabIndex = 7;
    // 
    // dateTimePicker4
    // 
    this.dateTimePicker4.CustomFormat = "yyyy-mm-dd";
    this.dateTimePicker4.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
    this.dateTimePicker4.Location = new System.Drawing.Point(92124);
    this.dateTimePicker4.Name = "dateTimePicker4";
    this.dateTimePicker4.Size = new System.Drawing.Size(20021);
    this.dateTimePicker4.TabIndex = 8;
    // 
    // Form1
    // 
    this.AutoScaleDimensions = new System.Drawing.SizeF(6F13F);
    this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    this.ClientSize = new System.Drawing.Size(348192);
    this.Controls.Add(this.dateTimePicker4);
    this.Controls.Add(this.dateTimePicker3);
    this.Controls.Add(this.dateTimePicker2);
    this.Controls.Add(this.label4);
    this.Controls.Add(this.label3);
    this.Controls.Add(this.label2);
    this.Controls.Add(this.label1);
    this.Controls.Add(this.dateTimePicker1);
    this.Font = new System.Drawing.Font("Tahoma"8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
    this.Name = "Form1";
    this.Text = "Date Controls";
    this.ResumeLayout(false);
    this.PerformLayout();

  }

  [STAThread]
  static void Main()
  {
    Application.EnableVisualStyles();
    Application.Run(new Form1());
  }

}


           
       
Related examples in the same category
1.Set DateTimePicker Min Date and Max DateSet DateTimePicker Min Date and Max Date
2.DateTimePicker Value changed event (Selected event)DateTimePicker Value changed event (Selected event)
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.