0% found this document useful (0 votes)
47 views2 pages

Date Time Picker

The document discusses a lecture on using date time pickers in visual programming. It demonstrates how to extract different parts of a date, like day of week, year, and month from a date time picker. It also shows how to calculate the difference between two date time values in days and add months to a selected date. The code examples use C# and Windows forms to implement these features with date time pickers.

Uploaded by

Jatt 7626
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views2 pages

Date Time Picker

The document discusses a lecture on using date time pickers in visual programming. It demonstrates how to extract different parts of a date, like day of week, year, and month from a date time picker. It also shows how to calculate the difference between two date time values in days and add months to a selected date. The code examples use C# and Windows forms to implement these features with date time pickers.

Uploaded by

Jatt 7626
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

VISUAL PROGRAMMING FALL-2014 Instructor Name: Adil Shaheen

Lecture # 12:

Objective:

 Date Time Picker

Date Time Picker:

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

private void btnDate_Click(object sender, EventArgs e)


VISUAL PROGRAMMING FALL-2014 Instructor Name: Adil Shaheen

{
MessageBox.Show(dateTimePicker1.Value.ToShortDateString());
}

private void btnTime_Click(object sender, EventArgs e)


{
MessageBox.Show(dateTimePicker1.Value.ToShortTimeString());
}

private void btnBreak_Click(object sender, EventArgs e)


{
txtDay.Text = dateTimePicker1.Value.DayOfWeek.ToString();
txtYear.Text = dateTimePicker1.Value.Year.ToString();
txtMonth.Text = dateTimePicker1.Value.Month.ToString();
}

private void button1_Click(object sender, EventArgs e)


{

txtAge.Text=dateTimePicker1.Value.Subtract(dateTimePicker2.Value).TotalDays.T
oString();
}

private void btnShowNew_Click(object sender, EventArgs e)


{
txt.Text =
dateTimePicker1.Value.AddMonths(int.Parse(txtAddMonths.Text)).ToShortDateStri
ng();
}
}
}

You might also like