1. Winform User control has two panels A, B. A docked to left, B docked to fill.
2. Panel A has two buttons (no events), panel B has two label and two TextBoxes (no events).
3. Adding user control to a Form using given lines, this form has no other control.
public partial class Form1 : Form
{
private UserControl1 userControl;
public Form1()
{
InitializeComponent();
for (int i = 0; i <1000; i++)
{
userControl = new UserControl1();
userControl.Dock = DockStyle.Top;
Controls.Add(userControl);
}
}
}
4. Given below error occurs at line
Application.Run(new Form1());
, any solution to add large number of user controls to a form?
System.ComponentModel.Win32Exception
HResult=0x80004005
Message=Error creating window handle.
Source=System.Windows.Forms
StackTrace:
at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)
at System.Windows.Forms.Control.CreateHandle()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
What I have tried:
looking for solution to resolve this issue?