DateTimePicker Value changed event (Selected event) : DateTimePicker « GUI Windows Form « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Design Patterns
8.Development Class
9.Event
10.File Stream
11.Generics
12.GUI Windows Form
13.Language Basics
14.LINQ
15.Network
16.Office
17.Reflection
18.Regular Expressions
19.Security
20.Services Event
21.Thread
22.Web Services
23.Windows
24.Windows Presentation Foundation
25.XML
26.XML LINQ
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » GUI Windows Form » DateTimePickerScreenshots 
DateTimePicker Value changed event (Selected event)
DateTimePicker Value changed event (Selected event)


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

public class Form1 : Form
{
    private System.Windows.Forms.DateTimePicker dateTimePickerDropOff;
    private System.Windows.Forms.Label outputLabel;
    private System.Windows.Forms.Label deliveryLabel;
    private System.Windows.Forms.Label dropOffLabel;
    public Form1() {
        InitializeComponent();
        dateTimePickerDropOff.MinDate = DateTime.Today;
        dateTimePickerDropOff.MaxDate = DateTime.Today.AddYears);
  }

   private void dateTimePickerDropOff_ValueChangedobject sender, EventArgs e )
   {
      DateTime dropOffDate = dateTimePickerDropOff.Value;

      if dropOffDate.DayOfWeek == DayOfWeek.Friday ||
         dropOffDate.DayOfWeek == DayOfWeek.Saturday ||
         dropOffDate.DayOfWeek == DayOfWeek.Sunday )

         outputLabel.Text = dropOffDate.AddDays).ToLongDateString();
      else
         outputLabel.Text = dropOffDate.AddDays).ToLongDateString();
   }

   private void InitializeComponent()
   {
      this.dateTimePickerDropOff = new System.Windows.Forms.DateTimePicker();
      this.outputLabel = new System.Windows.Forms.Label();
      this.deliveryLabel = new System.Windows.Forms.Label();
      this.dropOffLabel = new System.Windows.Forms.Label();
      this.SuspendLayout();
      // 
      // dateTimePickerDropOff
      // 
      this.dateTimePickerDropOff.Location = new System.Drawing.Point(3139);
      this.dateTimePickerDropOff.Name = "dateTimePickerDropOff";
      this.dateTimePickerDropOff.Size = new System.Drawing.Size(20020);
      this.dateTimePickerDropOff.TabIndex = 0;
      this.dateTimePickerDropOff.ValueChanged += new System.EventHandler(this.dateTimePickerDropOff_ValueChanged);
      // 
      // outputLabel
      // 
      this.outputLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
      this.outputLabel.Location = new System.Drawing.Point(31108);
      this.outputLabel.Name = "outputLabel";
      this.outputLabel.Size = new System.Drawing.Size(20023);
      this.outputLabel.TabIndex = 1;
      // 
      // deliveryLabel
      // 
      this.deliveryLabel.AutoSize = true;
      this.deliveryLabel.Location = new System.Drawing.Point(3095);
      this.deliveryLabel.Name = "deliveryLabel";
      this.deliveryLabel.Size = new System.Drawing.Size(11913);
      this.deliveryLabel.TabIndex = 2;
      // 
      // dropOffLabel
      // 
      this.dropOffLabel.AutoSize = true;
      this.dropOffLabel.Location = new System.Drawing.Point(3023);
      this.dropOffLabel.Name = "dropOffLabel";
      this.dropOffLabel.Size = new System.Drawing.Size(7213);
      this.dropOffLabel.TabIndex = 3;
      this.dropOffLabel.Text = "Drop Off Date:";
      // 
      // DateTimePickerForm
      // 
      this.AutoScaleDimensions = new System.Drawing.SizeF(6F13F);
      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
      this.ClientSize = new System.Drawing.Size(262235);
      this.Controls.Add(this.dropOffLabel);
      this.Controls.Add(this.deliveryLabel);
      this.Controls.Add(this.outputLabel);
      this.Controls.Add(this.dateTimePickerDropOff);
      this.Name = "DateTimePickerForm";
      this.Text = "DateTimePickerTest";
      this.ResumeLayout(false);
      this.PerformLayout();
 
    }
   [STAThread]
   static void Main()
  {
    Application.EnableVisualStyles();
    Application.Run(new Form1());
  }

}


           
       
Related examples in the same category
1.Set DateTimePicker Min Date and Max DateSet DateTimePicker Min Date and Max Date
2.DateTimePicker Format: Short, Time, default and Custom FormatDateTimePicker Format: Short, Time, default and Custom Format
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.