I am developing a VB.NET application in VS2008. It creates a large number of controls on the form and in the forms containers. When the number of controls reacech several thousends the program abends with the error: "Error creating window handle". Tests I have done indicates there is a max number of controls that can be added.
Is there a safe way to increace the max number of handels?
Or is it safer to rewrite the program to avoid so manny controls simultainiously?
My test appl looks like this:
Public Class Form1
Dim lbl() As Label
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim X As Integer
For X = 1 To 10000
lbl(X) = New Label
lbl(X).Text = X
lbl(X).Location = New Point(100, 20 * X)
lbl(X).AutoSize = True
The full error report is attached. Error-creating-window-handle.txt