Home > DeveloperSection > Forums > How can I work with DateTimePicker control?
Mark Devid
Mark Devid

Total Post:101

Points:707
Posted on    June-15-2013 5:31 AM

 C# C# 
Ratings:


 1 Reply(s)
 795  View(s)
Rate this:
Hi Experts,

How can I work with DateTimePicker control?

Thanks in advance.



Sumit Kesarwani

Total Post:378

Points:2694
Posted on    June-15-2013 6:49 AM

Hi Mark,

You can use the following code:

using System;

using System.Drawing;

using System.Windows.Forms;

 

namespace WindowsFormsApplication1

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

 

        private void Form1_Load(object sender, EventArgs e)

        {

            dateTimePicker1.Format = DateTimePickerFormat.Short;

            dateTimePicker1.Value = DateTime.Today;

        }

 

        private void button1_Click(object sender, EventArgs e)

        {

            DateTime iDate;

            iDate = dateTimePicker1.Value;

            MessageBox.Show("Selected date is " + iDate);

        }

    }

}


Don't want to miss updates? Please click the below button!

Follow MindStick