G
Guest
hi all,
I encounter problems when calling Form.ShowDialog() in a
ComboBox.SelectedIndexChanged-EventHandler. After the EventHandler is
executed a SEHException is thrown. This only happens if EnableVisualStyles
was called (see sample code).
Is this a known problem? is there a workaround other than not using
VisualStyles?
pp
VS 2003 (7.1.3088)
..NET 1.1 (1.1.4322)
#####code#####
using System;
using System.Windows.Forms;
namespace EnableVisualStylesComboBox
{
public class Form1 : Form
{
private System.Windows.Forms.ComboBox comboBox1;
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
comboBox1.Items.Add("Item 0");
}
private void comboBox1_SelectedIndexChanged(object sender,
System.EventArgs e)
{
new Form().ShowDialog();
}
#region dispose
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#endregion
#region designer
private void InitializeComponent()
{
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
//
// comboBox1
//
this.comboBox1.Location = new System.Drawing.Point(20, 20);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(250, 21);
this.comboBox1.TabIndex = 0;
this.comboBox1.Text = "Select an item and close the popup form.";
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, 66);
this.Controls.Add(this.comboBox1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.DoEvents();
Application.Run(new Form1());
}
}
}
I encounter problems when calling Form.ShowDialog() in a
ComboBox.SelectedIndexChanged-EventHandler. After the EventHandler is
executed a SEHException is thrown. This only happens if EnableVisualStyles
was called (see sample code).
Is this a known problem? is there a workaround other than not using
VisualStyles?
pp
VS 2003 (7.1.3088)
..NET 1.1 (1.1.4322)
#####code#####
using System;
using System.Windows.Forms;
namespace EnableVisualStylesComboBox
{
public class Form1 : Form
{
private System.Windows.Forms.ComboBox comboBox1;
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
comboBox1.Items.Add("Item 0");
}
private void comboBox1_SelectedIndexChanged(object sender,
System.EventArgs e)
{
new Form().ShowDialog();
}
#region dispose
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#endregion
#region designer
private void InitializeComponent()
{
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
//
// comboBox1
//
this.comboBox1.Location = new System.Drawing.Point(20, 20);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(250, 21);
this.comboBox1.TabIndex = 0;
this.comboBox1.Text = "Select an item and close the popup form.";
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, 66);
this.Controls.Add(this.comboBox1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.DoEvents();
Application.Run(new Form1());
}
}
}