Example with DateTimePicker :-



Add a new Form i.e.,FormDateTimePickerto the Windows Application WABasics

Create two labels,one textbox and one DateTimePicker Control & set the following properties to them

label1:-

     Text      :         lblSelectDate
     Name     :         Select Any Date

textbox1:-

     Name     :         txtSample

dateTimePicker1:-

Name          :         dtpickerDate


Design :-



 Generate theEventHandler for dateTimePicker1  ValueChanged Event
& write the following code in Source[FormDateTimePicker.cs] 

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 WABasics
{
    public partial class FormDateTimePicker : Form
    {
        public FormDateTimePicker()
        {
            InitializeComponent();
        }

        private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
        {
            txtDate.Text = dtpickerSample.Value.ToString();
        }
    }
}




Result :-


No comments:

Post a Comment