How to Get Date From DateTimePicker Using Window Application C#


Get Date From DateTimePicker 

Get the Date Value From DatetimePicker using  c#  in Window Application



First Add the - New Window Form - Add the DateTimePicker From ToolBox  









Next - Add the TextBox From Toolbox For Display the Month











Next - Double click the DateTimePicker 









Show Date with Time







C# Coding


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace QueryWindows
{
    public partial class datepickerMonth : Form
    {
        public datepickerMonth()
        {
            InitializeComponent();
        }

     private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
       
 {

            textBox1.Text = dateTimePicker1.Value.Date.ToString();


        }
    }
}



OUTPUT






Only Show Date 






C# Coding


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace QueryWindows
{
    public partial class datepickerMonth : Form
    {
        public datepickerMonth()
        {
            InitializeComponent();
        }

    private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
        {


        textBox1.Text = dateTimePicker1.Value.Date.ToShortDateString();


        }
    }

}





OUTPUT







Show the  Full Date Month ,Day, Year






C# Coding


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace QueryWindows
{
    public partial class datepickerMonth : Form
    {
        public datepickerMonth()
        {
            InitializeComponent();
        }

     private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
        {

          textBox1.Text = dateTimePicker1.Value.Date.ToLongDateString();


        }


    }


}



OUTPUT



0 comments:

Post a Comment