I have a treeview and based on the treeview elements, I have a listview on the right. SO almost UI is the look of Windows Explorer. So, now the problem I am facing is when I delete a large number of objects from the list going to the right, the tree on the left side becomes partially colored (a small part that I can tell). When I complete the CLR exclusion from the VS IDE, it points to the string sampletree.EndUpdate (); with an exception to the memory. When I add the next item in the list, everything becomes normal, I mean that the tree is completely painted Exception I get
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()
Do you have any ideas why my tree drawing is completely painted with only part and whole colors of the modification? code snippet is shown below
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();
UPDATE I use Font this way
case State.Modified: NodeFont = new Font(TreeView.Font, FontStyle.Bold); break;
This causes problems.