N
Nitin Koshy
/*Code Start*/
using System;
using System.ComponentModel;
using System.Windows.Forms;
namespace WindowsApplication1
{
public class Form1 : System.Windows.Forms.Form
{
private DateTimePicker dateTimePicker1;
private DateTimePicker dateTimePicker2;
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
private void InitializeComponent()
{
this.dateTimePicker1 = new
System.Windows.Forms.DateTimePicker();
this.dateTimePicker2 = new
System.Windows.Forms.DateTimePicker();
this.SuspendLayout();
//
// dateTimePicker1
//
this.dateTimePicker1.CustomFormat = "hh:mm tt";
this.dateTimePicker1.Format =
System.Windows.Forms.DateTimePickerFormat.Custom;
this.dateTimePicker1.Location = new System.Drawing.Point(40,
56);
this.dateTimePicker1.Name = "dateTimePicker1";
this.dateTimePicker1.ShowUpDown = true;
this.dateTimePicker1.Size = new System.Drawing.Size(136, 20);
this.dateTimePicker1.TabIndex = 0;
this.dateTimePicker1.ValueChanged += new
System.EventHandler(this.dateTimePicker1_ValueChanged);
//
// dateTimePicker2
//
this.dateTimePicker2.CustomFormat = "hh:mm tt";
this.dateTimePicker2.Format =
System.Windows.Forms.DateTimePickerFormat.Custom;
this.dateTimePicker2.Location = new System.Drawing.Point(40,
88);
this.dateTimePicker2.Name = "dateTimePicker2";
this.dateTimePicker2.ShowUpDown = true;
this.dateTimePicker2.Size = new System.Drawing.Size(136, 20);
this.dateTimePicker2.TabIndex = 1;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.dateTimePicker2);
this.Controls.Add(this.dateTimePicker1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
dateTimePicker1.MinDate = DateTime.Now;
dateTimePicker1.MaxDate = DateTime.Now.AddHours(2);
dateTimePicker2.MinDate = dateTimePicker1.MinDate;
dateTimePicker2.MaxDate = dateTimePicker1.MaxDate;
}
private void dateTimePicker1_ValueChanged(object sender,
System.EventArgs e)
{
dateTimePicker2.Value = dateTimePicker1.Value;
/*
* why do I get a System.ArgumentException here when I
decrement the value of dateTimePicker1
using the UpDown keys ?
Additional Info says : '16/05/2004 15:35:43' is not a valid
value for 'Value'.
'Value' should be between 'MinDate'
and 'MaxDate'
*/
}
}
}
/*Code End*/
Anyone got any clues to why I get the ArgumentException at
dateTimePicker1_ValueChanged please? Bug ?
Cheers,
Nitin Koshy
using System;
using System.ComponentModel;
using System.Windows.Forms;
namespace WindowsApplication1
{
public class Form1 : System.Windows.Forms.Form
{
private DateTimePicker dateTimePicker1;
private DateTimePicker dateTimePicker2;
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
private void InitializeComponent()
{
this.dateTimePicker1 = new
System.Windows.Forms.DateTimePicker();
this.dateTimePicker2 = new
System.Windows.Forms.DateTimePicker();
this.SuspendLayout();
//
// dateTimePicker1
//
this.dateTimePicker1.CustomFormat = "hh:mm tt";
this.dateTimePicker1.Format =
System.Windows.Forms.DateTimePickerFormat.Custom;
this.dateTimePicker1.Location = new System.Drawing.Point(40,
56);
this.dateTimePicker1.Name = "dateTimePicker1";
this.dateTimePicker1.ShowUpDown = true;
this.dateTimePicker1.Size = new System.Drawing.Size(136, 20);
this.dateTimePicker1.TabIndex = 0;
this.dateTimePicker1.ValueChanged += new
System.EventHandler(this.dateTimePicker1_ValueChanged);
//
// dateTimePicker2
//
this.dateTimePicker2.CustomFormat = "hh:mm tt";
this.dateTimePicker2.Format =
System.Windows.Forms.DateTimePickerFormat.Custom;
this.dateTimePicker2.Location = new System.Drawing.Point(40,
88);
this.dateTimePicker2.Name = "dateTimePicker2";
this.dateTimePicker2.ShowUpDown = true;
this.dateTimePicker2.Size = new System.Drawing.Size(136, 20);
this.dateTimePicker2.TabIndex = 1;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.dateTimePicker2);
this.Controls.Add(this.dateTimePicker1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
dateTimePicker1.MinDate = DateTime.Now;
dateTimePicker1.MaxDate = DateTime.Now.AddHours(2);
dateTimePicker2.MinDate = dateTimePicker1.MinDate;
dateTimePicker2.MaxDate = dateTimePicker1.MaxDate;
}
private void dateTimePicker1_ValueChanged(object sender,
System.EventArgs e)
{
dateTimePicker2.Value = dateTimePicker1.Value;
/*
* why do I get a System.ArgumentException here when I
decrement the value of dateTimePicker1
using the UpDown keys ?
Additional Info says : '16/05/2004 15:35:43' is not a valid
value for 'Value'.
'Value' should be between 'MinDate'
and 'MaxDate'
*/
}
}
}
/*Code End*/
Anyone got any clues to why I get the ArgumentException at
dateTimePicker1_ValueChanged please? Bug ?
Cheers,
Nitin Koshy