How can I work with DateTimePicker control?

Total Post:102

Points:714
C# 
C#
 1327  View(s)
Ratings:
Rate this:
Hi Experts,

How can I work with DateTimePicker control?

Thanks in advance.

  1. 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);
            }
        }
    }

      Modified On Mar-30-2018 03:58:35 AM

Answer