当前位置:编程学习 > C#/ASP.NET >>

高手请进,大量动态控件生成时的问题。有没有可能自制不需要句柄的控件???

在Form里面动态生成大量控件后。
Error creating window handle.System.Windows.FormsSystem.ComponentModel.Win32Exception: Error creating window handle.
   at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)
   at System.Windows.Forms.Control.CreateHandle()
   at System.Windows.Forms.Control.get_Handle()
   at System.Windows.Forms.Control.CreateGraphicsInternal()
   at System.Windows.Forms.ThreadExceptionDialog..ctor(Exception t)
   at System.Windows.Forms.ThreadExceptionDialog..ctor(Exception t)
   at System.Windows.Forms.ThreadContext.OnThreadException(Exception t)
   at System.Windows.Forms.Control.WndProcException(Exception e)
   at System.Windows.Forms.ControlNativeWindow.OnThreadException(Exception e)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
   at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
   at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
   at System.Windows.Forms.Control.set_Visible(Boolean value)
   at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
   at System.Windows.Forms.Form.ShowDialog()

查询很多网站说是windows默认句柄是10000个
加入动态生成了10000个左右的控件比如说10000Label,就会抛出以上exception

我想有没有可能自制不需要句柄的控件???

--------------------编程问答-------------------- 不要用控件,自己绘制ui
--------------------编程问答-------------------- 不用控件,自己绘制是一个解决方法,但是,前提是你的这些绘制出来的个体要不要可以移动,删除等等的操作,如果是的话,绘制的话就要反复刷新,可能会有些闪烁 --------------------编程问答-------------------- 我曾经开发过一个WinForm,能够容纳至少10000000数量级的UI元素(Button……),可惜是商业的,不能share,思路是自绘UI元素,自己处理UI响应。相当的复杂。

推荐使用WPF,控件没有Handle了,^_^ --------------------编程问答-------------------- 不明LZ在说什么 --------------------编程问答--------------------    遇到和楼主一样的问题了!  楼主现在解决了吗?  
补充:.NET技术 ,  组件/控件开发
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,