Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Checked DateTimePicker not firing ValueChanged event when XP theme is enabled

50 views
Skip to first unread message

Viktor

unread,
Aug 25, 2003, 12:20:27 PM8/25/03
to
Hi,

I have comboBox and dateTimePicker with a checkBox.

When certain item is selected in the comboBox it becomes hidden,
dateTimePicker becomes visible and checked.
If it is unchecked it hides, comboBox becomes visible again with the first
item selected.

The problem is when Windows XP theme is enabled (checkBox appears flat in
the dateTimePicker control), the ValueChanged event is not firing when
dateTimePicker is being unchecked for the first time after it has appeared.
If Windows XP theme is not enabled everything is fine and event is firing as
expected.

If somebody could advise if this is one is a bug or I am doing something
wrong here.
Thanks, Viktor

using System;

using System.Windows.Forms;

namespace WindowsApplication1

{

/// <summary>

/// Summary description for Form1.

/// </summary>

public class Form1 : System.Windows.Forms.Form

{

private System.Windows.Forms.DateTimePicker dateTimePicker1;

private System.Windows.Forms.ComboBox comboBox1;

/// <summary>

/// Required designer variable.

/// </summary>

private System.ComponentModel.Container components = null;

public Form1()

{

//

// Required for Windows Form Designer support

//

InitializeComponent();

//

// TODO: Add any constructor code after
InitializeComponent call

//

}

/// <summary>

/// Clean up any resources being used.

/// </summary>

protected override void Dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}

#region Windows Form Designer generated code

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.dateTimePicker1 = new
System.Windows.Forms.DateTimePicker();

this.comboBox1 = new System.Windows.Forms.ComboBox();

this.SuspendLayout();

//

// dateTimePicker1

//

this.dateTimePicker1.CustomFormat = "MMM d, yyyy h:mm tt";

this.dateTimePicker1.Format =
System.Windows.Forms.DateTimePickerFormat.Custom;

this.dateTimePicker1.Location = new
System.Drawing.Point(24, 56);

this.dateTimePicker1.Name = "dateTimePicker1";

this.dateTimePicker1.ShowCheckBox = true;

this.dateTimePicker1.Size = new System.Drawing.Size(184,
20);

this.dateTimePicker1.TabIndex = 0;

this.dateTimePicker1.Visible = false;

this.dateTimePicker1.ValueChanged += new
System.EventHandler(this.dateTimePicker1_ValueChanged);

//

// comboBox1

//

this.comboBox1.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList;

this.comboBox1.Items.AddRange(new object[] {


"Hide DateTimePicker",


"Show DateTimePicker"});

this.comboBox1.Location = new System.Drawing.Point(24,
24);

this.comboBox1.Name = "comboBox1";

this.comboBox1.Size = new System.Drawing.Size(184, 21);

this.comboBox1.TabIndex = 1;

this.comboBox1.SelectedIndexChanged += new
System.EventHandler(this.comboBox1_SelectedIndexChanged);

//

// Form1

//

this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);

this.ClientSize = new System.Drawing.Size(292, 266);

this.Controls.AddRange(new System.Windows.Forms.Control[]
{


this.comboBox1,


this.dateTimePicker1});

this.Name = "Form1";

this.Text = "Form1";

this.Load += new System.EventHandler(this.Form1_Load);

this.ResumeLayout(false);

}

#endregion

/// <summary>

/// The main entry point for the application.

/// </summary>

[STAThread]

static void Main()

{

Application.Run(new Form1());

}

private void comboBox1_SelectedIndexChanged(object sender,
System.EventArgs e)

{

if(comboBox1.SelectedIndex==1)

{

dateTimePicker1.Checked=true;

dateTimePicker1.Show();

dateTimePicker1.Focus();

comboBox1.Hide();

}

}

private void dateTimePicker1_ValueChanged(object sender,
System.EventArgs e)

{

Console.WriteLine(dateTimePicker1.Checked.ToString());

if(!dateTimePicker1.Checked)

{

comboBox1.SelectedIndex=0;

comboBox1.Show();

comboBox1.Focus();

dateTimePicker1.Hide();

}

}

private void Form1_Load(object sender, System.EventArgs e)

{

comboBox1.SelectedIndex=0;

}

}

}

To enable Windows XP theme place the following
WindowsApplication1.exe.manifest in the location where
WindowsApplication1.exe is launched from

<?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.exe"
type="win32"
/>
<description>.NET control deployment tool</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>


0 new messages