We build a complicate user control using the TabStrip with many TextBoxes in it and experience the program crashing with “System.ComponentModel.Win32Exception: Error creating window handle” after creating a certain amoumt of that controls.
To isolate the problem, we built simple WinForm program in which there is a dummy usercontrol using an Actipro TabStrip with two tab pages and placing 100 text boxes in each page. The testing program crashes with the above exception after creating about 50 usercontrols.
We were suspecting that was because it runs out resource, so we built another dummy usercontrol by putting 200 textboxes in a MS TabControl instead of the Actipro TabStrip, but we could create hundreds of instances of this usercontrol without crashing.
We could not understand why the TabStrip has such a big scalability difference from the MS TabControl. In addition to change our design to reduce the number of text boxes in the usercontrol, any other thing we could do to resolve the problem?
Our system is VS2005 with UIStudio 1.5.43. We also tested the latest UIStudio 2.0 trial version with the same result.
Following are some of our testing code:
To isolate the problem, we built simple WinForm program in which there is a dummy usercontrol using an Actipro TabStrip with two tab pages and placing 100 text boxes in each page. The testing program crashes with the above exception after creating about 50 usercontrols.
We were suspecting that was because it runs out resource, so we built another dummy usercontrol by putting 200 textboxes in a MS TabControl instead of the Actipro TabStrip, but we could create hundreds of instances of this usercontrol without crashing.
We could not understand why the TabStrip has such a big scalability difference from the MS TabControl. In addition to change our design to reduce the number of text boxes in the usercontrol, any other thing we could do to resolve the problem?
Our system is VS2005 with UIStudio 1.5.43. We also tested the latest UIStudio 2.0 trial version with the same result.
Following are some of our testing code:
/// <summary>
/// A user control using Actipro tabstrip
/// </summary>
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
//Add some text boxes to the tab pages.
for (int i = 0; i < 100; i++)
{
TextBox boxForPage1 = new TextBox();
this.tabStripPage1.Controls.Add(boxForPage1);
TextBox boxForPage2 = new TextBox();
this.tabStripPage1.Controls.Add(boxForPage2);
}
}
}
/// <summary>
/// A user control using MS tabcontrol
/// </summary>
public partial class UserControl2 : UserControl
{
public UserControl2()
{
InitializeComponent();
for (int i = 0; i < 100; i++)
{
TextBox boxForPage1 = new TextBox();
this.tabPage1.Controls.Add(boxForPage1);
TextBox boxForPage2 = new TextBox();
this.tabPage2.Controls.Add(boxForPage2);
}
}
}
public partial class Form1 : Form
{
private int _MSTotal = 0;
private int _ActiproTotal = 0;
public Form1()
{
InitializeComponent();
}
/// <summary>
/// Creates UserControl2 - MS tab control
/// </summary>
private void button2_Click(object sender, EventArgs e)
{
for (int i = 0; i < 5; i++)
{
UserControl2 theUserControl = new UserControl2();
}
_MSTotal += 5;
this.textBox2.Text = _MSTotal.ToString();
}
/// <summary>
/// Creates UserControl1 - Actipro tabstrip.
/// Systems crashes with the System.ComponentModel.Win32Exception: Error creating window handle
/// after creating about 50 UserControl1s
/// </summary>
private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < 5; i++)
{
UserControl1 theUserControl = new UserControl1();
}
_ActiproTotal += 5;
this.textBox1.Text = _ActiproTotal.ToString();
}
}