在Winform窗体上动态添加自定义控件,添加12个是没问题,窗口可以弹出,添加13个时,进程就自动终止了,用事件查看器有如下信息:应用程序: DynamicAddControlsTest.exe
Framework 版本: v4.0.30319
说明: 由于未经处理的异常,进程终止。
异常信息: System.ComponentModel.Win32Exception
堆栈:
   在 System.Windows.Forms.NativeWindow.CreateHandle(System.Windows.Forms.CreateParams)
   在 System.Windows.Forms.Control.CreateHandle()
   在 System.Windows.Forms.Control.get_Handle()
   在 System.Windows.Forms.Application.ParkHandle(System.Windows.Forms.CreateParams)
   在 System.Windows.Forms.Control.CreateHandle()
   在 System.Windows.Forms.Control.get_Handle()
   在 System.Windows.Forms.Control.CreateGraphicsInternal()
   在 System.Windows.Forms.ThreadExceptionDialog..ctor(System.Exception)
   在 System.Windows.Forms.Application+ThreadContext.OnThreadException(System.Exception)
   在 System.Windows.Forms.Control.WndProcException(System.Exception)
   在 System.Windows.Forms.Control+ControlNativeWindow.OnThreadException(System.Exception)
   在 System.Windows.Forms.NativeWindow.Callback(IntPtr, Int32, IntPtr, IntPtr)
   在 System.Windows.Forms.SafeNativeMethods.ShowWindow(System.Runtime.InteropServices.HandleRef, Int32)
   在 System.Windows.Forms.Control.SetVisibleCore(Boolean)
   在 System.Windows.Forms.Form.SetVisibleCore(Boolean)
   在 System.Windows.Forms.Control.set_Visible(Boolean)
   在 System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(Int32, System.Windows.Forms.ApplicationContext)
   在 System.Windows.Forms.Application+ThreadContext.RunMessageLoop(Int32, System.Windows.Forms.ApplicationContext)
   在 System.Windows.Forms.Application.Run(System.Windows.Forms.Form)
   在 DynamicAddControlsTest.Program.Main()求各位帮帮忙!!!