How to: Display DATE format the DateTimePicker Control in in -- Windows Forms Application c#

How to: Display DATE format the DateTimePicker Control::


If you want your application to enable users to select a date and time, and to display that date and time in the specified format, use the date Time Picker control. The following procedure shows how to use the dateTimePicker control to display the time.


C#(Code)......
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 datetimepicker_maskedtextbox
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            dateTimePicker1.MinDate = DateTime.Now;
            dateTimePicker1.MaxDate = dateTimePicker1.MinDate.AddDays(60);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            MessageBox.Show(dateTimePicker1.Value.ToShortDateString());
        }
    }

}


Comments