我有一个树视图和基于TreeView的项目,我有右侧的列表视图。所以几乎UI是我们的Windows资源管理器的外观。所以现在我面临的问题是,当我从列表视图中删除大量的对象来到右侧时,左侧的树视图变成部分画(我可以说小部分)。当我从VS IDE获得CLR excpetion时,它指向line sampletree.EndUpdate();除了内存不足之外。当我加入的ListView一切下一个项目都正常我的意思是树状完全画 异常我得到是.net中的内存异常winform treeview
System.OutOfMemoryException occurred
Message=Out of memory.
Source=System.Drawing
StackTrace:
at System.Drawing.Graphics.FromHdcInternal(IntPtr hdc)
at System.Drawing.Font.ToLogFont(Object logFont)
at System.Drawing.Font.ToHfont()
at System.Windows.Forms.Control.FontHandleWrapper..ctor(Font font)
at System.Windows.Forms.OwnerDrawPropertyBag.get_FontHandle()
at System.Windows.Forms.TreeView.CustomDraw(Message& m)
at System.Windows.Forms.TreeView.WmNotify(Message& m)
at System.Windows.Forms.TreeView.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)
at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.Control.ReflectMessageInternal(IntPtr hWnd, Message& m)
at System.Windows.Forms.Control.WmNotify(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.UserControl.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)
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.Control.DefWndProc(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.TreeView.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)
at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, Int32 wParam, Int32 lParam)
at System.Windows.Forms.Control.EndUpdateInternal(Boolean invalidate)
at System.Windows.Forms.TreeView.EndUpdate()
你有我为什么我的TreeView的是只涂一个samll一部分,并连续修改油漆充分的任何想法?代码片段显示belowe
if((values != null) &&
(values .OverallState != ToBeDeleted) &&
(values .OverallState != .Deleted))
{
TreeView tree = this.TreeView;
if(tree != null)
{
tree.BeginUpdate();
}
TryUpdate();
TryPopulate();
if(tree != null)
{
tree.EndUpdate(); // here exception coming
}
}
UPDATE 我使用的字体像这样
case State.Modified:
NodeFont = new Font(TreeView.Font, FontStyle.Bold);
break;
这是否漏水GDI资源使
做的winform树视图有任何已知的问题,或者任何索引变成-1? – vettori 2013-04-22 13:46:52
同样的问题在这里。任务管理器显示该进程创建了10,000个GDI字体句柄(然后崩溃,最大值为10,000)。只有当我同时创建很多节点时才会发生这种情况。 – dacap 2013-07-11 17:10:38