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.Date Time
8.Design Patterns
9.Development Class
10.Event
11.File Stream
12.Generics
13.GUI Windows Form
14.Internationalization I18N
15.Language Basics
16.LINQ
17.Network
18.Office
19.Reflection
20.Regular Expressions
21.Security
22.Services Event
23.Thread
24.Web Services
25.Windows
26.Windows Presentation Foundation
27.XML
28.XML LINQ
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
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.