We detected a bug (ValueChange Event not fired) in the DateTimePicker.
The bug only occurs when we use the Microsoft.Windows.Common-Controls 6.
To reproduce the bug simply create a new Solution with a windows application project
Exchange the generated Form1.cs with the code below and put the manifest-file (which follows the code) in your exe-Directory (e.g. bin/Debug)
Run the Application an follow the instructions
ANY IDEAS TO SOLVE THE PROBLEM
***************************************************************
Here ist the code of Form1.c
***************************************************************
using System
using System.Windows.Forms
namespace WindowsApplication
public class Form1 : System.Windows.Forms.For
private System.Windows.Forms.DateTimePicker dtpSource
private System.Windows.Forms.Button apply
private System.Windows.Forms.DateTimePicker dtpTarget
private System.Windows.Forms.Label label1
private System.Windows.Forms.Label label2
private System.Windows.Forms.TextBox description
private System.Windows.Forms.TextBox textBox
public Form1(
InitializeComponent()
this.description.Text =
"IMPORTANT: the bug only occurs when you use Microsoft.Windows.Common-Controls 6.0 !!!\r\n
+ "1. Enter 27.02.2004 in Target\r\n
+ "2. Enter 26.02.2004 in Source\r\n
+ "3. Press the apply button\r\n
+ "4. Change target to 27.02.2004 again\r\n
+ "BUG: there is no valueChange event fired when you change the date to the previous value"
#region Windows Form Designer generated cod
private void InitializeComponent(
this.dtpSource = new System.Windows.Forms.DateTimePicker()
this.apply = new System.Windows.Forms.Button()
this.dtpTarget = new System.Windows.Forms.DateTimePicker()
this.textBox = new System.Windows.Forms.TextBox()
this.label1 = new System.Windows.Forms.Label()
this.label2 = new System.Windows.Forms.Label()
this.description = new System.Windows.Forms.TextBox()
this.SuspendLayout()
//
// dtpSourc
//
this.dtpSource.Format = System.Windows.Forms.DateTimePickerFormat.Short
this.dtpSource.Location = new System.Drawing.Point(24, 168)
this.dtpSource.Name = "dtpSource"
this.dtpSource.Size = new System.Drawing.Size(88, 20)
this.dtpSource.TabIndex = 0
this.dtpSource.Value = new System.DateTime(2004, 2, 26, 0, 0, 0, 0)
//
// appl
//
this.apply.Location = new System.Drawing.Point(128, 168)
this.apply.Name = "apply"
this.apply.TabIndex = 1
this.apply.Text = "apply ->"
this.apply.Click += new System.EventHandler(this.apply_Click)
//
// dtpTarge
//
this.dtpTarget.Format = System.Windows.Forms.DateTimePickerFormat.Short
this.dtpTarget.Location = new System.Drawing.Point(224, 168)
this.dtpTarget.Name = "dtpTarget"
this.dtpTarget.Size = new System.Drawing.Size(88, 20)
this.dtpTarget.TabIndex = 2
this.dtpTarget.Value = new System.DateTime(2004, 2, 26, 0, 0, 0, 0)
this.dtpTarget.ValueChanged += new System.EventHandler(this.dtpTarget_ValueChanged)
//
// textBo
//
this.textBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)))
this.textBox.Location = new System.Drawing.Point(24, 208)
this.textBox.Multiline = true
this.textBox.Name = "textBox"
this.textBox.Size = new System.Drawing.Size(528, 120)
this.textBox.TabIndex = 3
this.textBox.Text = ""
//
// label
//
this.label1.AutoSize = true
this.label1.Location = new System.Drawing.Point(24, 152)
this.label1.Name = "label1"
this.label1.Size = new System.Drawing.Size(40, 16)
this.label1.TabIndex = 4
this.label1.Text = "Source"
//
// label
//
this.label2.AutoSize = true
this.label2.Location = new System.Drawing.Point(224, 152)
this.label2.Name = "label2"
this.label2.Size = new System.Drawing.Size(37, 16)
this.label2.TabIndex = 4;
this.label2.Text = "Target";
//
// description
//
this.description.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.description.Location = new System.Drawing.Point(16, 16);
this.description.Multiline = true;
this.description.Name = "description";
this.description.ReadOnly = true;
this.description.Size = new System.Drawing.Size(536, 120);
this.description.TabIndex = 5;
this.description.Text = "";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(568, 347);
this.Controls.Add(this.description);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox);
this.Controls.Add(this.dtpTarget);
this.Controls.Add(this.apply);
this.Controls.Add(this.dtpSource);
this.Controls.Add(this.label2);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void apply_Click(object sender, System.EventArgs e)
{
this.textBox.Text = string.Empty;
this.dtpTarget.Value = this.dtpSource.Value;
}
private void dtpTarget_ValueChanged(object sender, System.EventArgs e)
{
string text = "ValueChanged: " + this.dtpTarget.Value + "\r\n";
this.textBox.AppendText(text);
}
}
}
****************************************************************
Here ist the WindowsApplication1.exe.manifest file:
****************************************************************
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"><assemblyIdentity
version="1.0.0.0"
processorArchitecture="X86"
name="WindowsApplication1"
type="win32"
/><description>.NET control deployment tool</description><dependency><dependentAssembly><assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.10.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"
/></dependentAssembly></dependency></assembly>