HOW CAN I WORK WITH DATETIMEPICKER CONTROL?

Mark Devid

Total Post:102

Points:714
Posted by  Mark Devid
C# 
C#
 1034  View(s)
Ratings:
Rate this:
Hi Experts,

How can I work with DateTimePicker control?

Thanks in advance.

  1. Sumit Kesarwani

    Post:378

    Points:2694
    Re: How can I work with DateTimePicker control?

    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);

            }

        }

    }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!